-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Friday 2008-01-25 at 10:01 -0500, james wright wrote:
On Friday 25 January 2008 08:37:24 am Ken Schneider wrote:
Try using expect to do what you want. I used expect when connecting to Cisco routers to do configuration changes with the password embedde3d in the expect script.
Ah, expect! Got the name wrong.
You should obviously read the man page, but if you want to start having fun right away, paste the below script into a file, change the name, host, and password to fit your environment and run it with:
expect FileYouSaved
Here is the script:
#!/usr/bin/expect spawn ssh -l UserNameHere 192.168.1.111 expect Password: send "PassWord\n" interact
Note: You need the \n at the end of your password.
Good! Seems easy... but doesn't quite work. I have: #!/usr/bin/expect spawn ssh -l 1234 router #expect 1234@router's password: expect Password: send "password\n" interact but I get: cer@nimrodel:~> router_ssh spawn ssh -l 1234 router 1234@router's password: and it doesn't enter. I modify the script: #!/usr/bin/expect spawn ssh -l 1234 router expect 1234@router's password: send "password\n" interact and now I get: 1234@router's password: invalid command name "password:" while executing "password:" invoked from within "expect 1234@router's password: " (file "/home/cer/bin/router_ssh" line 3) I escape the ' with \ and still I get: cer@nimrodel:~> router_ssh spawn ssh -l 1234 router 1234@router's password: invalid command name "password:" while executing "password:" invoked from within "expect 1234@router\'s password: " (file "/home/cer/bin/router_ssh" line 3) Why is it trying to execute "password"? That's absurd. Ah! I got it! expect "1234@router's password: " Well... now I want one step more: #!/usr/bin/expect spawn ssh -l 1234 router expect "1234@router's password: " #expect Password: send "****\n" send "ping -c 50000 192.168.1.12" interact cer@nimrodel:~> router_ssh spawn ssh -l 1234 router 1234@router's password: -> The ping command is not sent... Ah, got it! expect "1234@router's password: " send "****\n" expect " ->" send "ping -c 50000 192.168.1.12\n" interact THANK YOU! :-))) (I need the router to send pings to my PC, or this computer stops working - - that's another story, there is a bugzilla about it) - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFHmg8ntTMYHG2NR9URAk/sAKCAY8ieG/08uH8HeItcMjsih1NN6gCfRial JltnbqyJ9o9SUc3iyeLLZO8= =eKVD -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org