OK I won't go in to the problems with telnet. But with ssh you don't need to create a script like that. All you need to do is create sshkeys copy the public key to the .ssh directory in any machine you wish to login to. Once that is done all you need to do is run
ssh server -l username -c 'execute the command' if you want X services ssh server -l username 'export DISPLAY=yourmachine:0.0' -X -c 'xterm -fg green -bg black' It's a little less complicated and gets the job done just as quick > hello, > > a question very similar to the one i am about to ask was posted to the > SLUG list last year. however, i could find no reply. > > the problem is as follows: > > the script that i have put together telnets in OK but once having done > so the script stalls for approx 10 seconds. i suspect that the 10 > seconds is the default timeout for Expect. the script following the > password section is not run. during the timeout period i do receive > several ESC characters. i suspect that these are a part of the telnet > setup dialog that the two machines conduct when logging in. > > my script, though plain, runs as follows: > > #!/usr/bin/expect -f > set addy devmachine > set user devuser > set password PASSWD > > spawn telnet $addy > > expect "Username:" > send "$user\r" > > expect "Password:" > send "$password\r" > > expect "LOGIN PROMPT" > send "COMMAND TO BE EXECUTED" > > the last EXPECT/SEND pair do not execute. > > i feel that this has something to do with the telnet session not setting > up correctly. i suspect that the EXPECT command captures the telnet > control characters rather then passing them to the telnet session. i do > stand corrected on this though. > > any suggestions on how this can be made to work would be gratefully > accepted. > > NOTE: i am aware of the security issues surrounding TELNET. > > regards, > > Lucas > > > > > ************************************************************************ > This email and any files transmitted with it may be legally privileged > and confidential. If you are not the intended recipient of this email, > you must not disclose or use the information contained in it. If you > have received this email in error, please notify us by return email and > permanently delete the document. > ************************************************************************ > > -- > SLUG - Sydney Linux User's Group - http://slug.org.au/ > More Info: http://lists.slug.org.au/listinfo/slug -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
