i am trying to use telnet inside of a ksh script.
i would like to do like the following:
#!/bin/ksh
...
user="user"
hostname="hostname"
telnet -l $user $hostname |&
wait
#end of the ksh
and with this piece of code, i would like to telnet another machine, and let the user use telnet to work on the other machine.
It's like if the command was typed directly into the command prompt: the user then enters the password and continues working on the other machie until he types "exit" then he returns back to the first machine.
But it doesn't seem to work, i get "connection closed by foreign host" at the end of my script.
I hope you understand my problem. Can you please help ?
And idially, i would also like the script to enter the password automatically, if possible, but it's optionnal.
thank you very much.
$ uname -a
SunOS machinename 5.10 Generic_127111-06 sun4u sparc SUNW,Sun-Fire-V490
Might be easier with the "rlogin" command?
Providing that the account name exists on both computers, "rlogin" can be configured to log in without a password.
you're right it's easier.
but actually i had a problem using rlogin, it takes a long time before returning an error:
prompt $ rlogin XX.XX.XX.XX
::ffff:XX.XX.XX.XX: Connection refused
prompt $ telnet XX.XX.XX.XX
Trying XX.XX.XX.XX...
Connected to XX.XX.XX.XX.
Escape character is '^]'.
login:
but you know what, it's because i was using rlogin on the same machine, i guess that was the problem.
Thank you very much, i'm gonna switch back to "rlogin"
---------- Post updated at 02:19 PM ---------- Previous update was at 02:03 PM ----------
actually the was never the problem (rlogin to own machine)
do you know what could cause the "Connection refused" problem when using rlogin instade of telnet ?
#!/bin/ksh
...
user="user"
hostname="hostname"
telnet -l $user $hostname
#end of the ksh
But to use telnet or rlogin, the remote system must be configured to allow it. rlogin is a very insecure program and most decent sys admins will prohibit it. (telnet isn't great for security either but it is better than rlogin.) If you get "connection refused" it is disabled, probably by intent.