Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remote login via korn shell script

Status
Not open for further replies.

ruse7013

Programmer
Apr 10, 2003
25
US
How can I connect to a remote machine using rlogin (or other command) from within a korn shell script?

Also, if possible - how can I provide the userid and password automatically, so the script does not stop waiting for the password?

Thank you.
 
The Korn shell is not stopping you. You should be able to rsh right from it, I do it all the time. It is most likely that your rhosts are setup incorrectly. [Or correctly and they do not want you to attempt what you are doing]

Rather than repeat the manual for you, or worse give you the RTFM response (my #1 pet irritant), look at rsh on your server (find the manual, I did not find the man page helpful). An even better option is to setup ssh. It is fairly easy to setup and once you build trusted keys, a 30 second process, sigining in requires neither an id or password. You scripts "just run"


-cheers
 
gamerland and marsd,

Thank you for your reply. Still have some challenges...

My code is:
--------------------------
!/usr/bin/ksh

rksh remotehost find ${HOME} -name somefile

exit 0
--------------------------

Also, there is a .rhosts file in the 'remotehost' ${HOME} dir in the following format:
<IP Address> <mymachine.domain.com> <alias>, for instance:
192.168.100.100 mymachine.domain.com mymachine

After executing my script, I get this error:
--------------------------
rksh: remotehost: cannot open
--------------------------

What's the issue?
Thanks for your help.



 
Sorry, the first line of my code reads:
#!/usr/bin/ksh
 
I see the issue:

rksh remotehost find ${HOME} -name somefile
should be

rsh remotehost find ${HOME} -name somefile

while rksh may appear logical, you are actually using the remote shell protocol, and it is shell independent. Also, to save yourself some problems later, always specify full directories on the remote server unless you are positive you know what HOME points to. For example:
rsh 123.123.123.123 ls /home/users/userid01

For other ksh info try here: it is a good overview.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top