Operating System - HP-UX
1752795 Members
6076 Online
108789 Solutions
New Discussion юеВ

how pass password to rexec in a script?

 
SOLVED
Go to solution
Arturo Galbiati
Esteemed Contributor

how pass password to rexec in a script?

Hi boys 10 point to assign:
how can I pass the user password to the rexec command in a script (possbiliy ksh)?
i.e: rexec $(hostname) -l dummyuser id

Art

8 REPLIES 8
Uday_S_Ankolekar
Honored Contributor
Solution

Re: how pass password to rexec in a script?

You can make use of expect utility. This can be used to automate tasks that require certain interactive responses like login password etc.

Get it from here:
http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.43/

OR..

If you want to use rexec command then possibly you can configure .rhosts or hosts.equiv to execute any r* commands without asking for password. man .rhosts or hosts.equiv for more

-USA
Good Luck..
Juan M Leon
Trusted Contributor

Re: how pass password to rexec in a script?

Hello Art, I will suggest something like the following lines

-------------------------------------------
echo "enter UID : \c"
read userid
echo "Enter password : \c"
stty -echo
read userpass
stty echo

for server in `cat myserverlist.txt`
do
(sleep 5
echo $userid
sleep 5
echo $userpass
sleep 5
echo bdf
echo ls ) | telnet $server
done
-----------------------------------------
myserverlist.txt is the file with your servers name, only one colum and as many lines as servers you want to automate.
Also in the section "echo bdf" and "echo ls" replace those lines with your actual commands to execute. remenber with in the "()" you always have to enter "echo" before the command.

Hope it works for you

Thanks

Juan
Juan M Leon
Trusted Contributor

Re: how pass password to rexec in a script?

I forgot you will have to add one more line entry before close the ")". the following "echo exit" or your script will remain in the current sheel and will not continue to the next server.

Thanks

Juan
Arturo Galbiati
Esteemed Contributor

Re: how pass password to rexec in a script?

Hi Juan,
solution to use telnet sounds good but in case the password trasmitted is wrong the scripy remain in hang, asking for new password, putting some dummy echoes causing that the user will be locked in a trusted environment and really Id' like to avoid this.

Any other contribute to this discussion?

TIA,
Art
Pete Randall
Outstanding Contributor

Re: how pass password to rexec in a script?

Art,

Expect is really the weapon of choice for this sort of thing.


Pete

Pete
RAC_1
Honored Contributor

Re: how pass password to rexec in a script?

Why expect, when you canuse native .netrc file.

man netrc. this file is used for ftp and rexec auto logins.

Anil
There is no substitute to HARDWORK
Tom Schroll
Frequent Advisor

Re: how pass password to rexec in a script?


I recommend OpenSSH as the most secure weapon of choice for remote commands. It is available on the Software Porting archive as a package. Once it is installed and working, you can use encrypted ssh keys to do passwordless authentication. I know this may be overkill in a closed environment, but if security is of any concern, it's clearly the best choice to replace any of the r* commands.

-- Tom
If it ain't broke, it needs optimized.
Arturo Galbiati
Esteemed Contributor

Re: how pass password to rexec in a script?

thanks Anil, I'll use .netrc file.
Art