I have Ubuntu 9.10 (and cannot change it in the near future due to testing) with expect5.45. Expect is working, but I have (at least) two issues. The first is that expect does not seem to be matching the string "password:". On my machine, the manual interaction appears as below:
root@Monkey2:~# rlogin $remoteAddress -l root
root@nn.nn.nnn.nnn's password:
Linux systest-desktop 2.6.31-22-generic #70-Ubuntu SMP Wed Dec 1 23:51:13 UTC 2010 i686
To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
72 packages can be updated.
70 updates are security updates.
Last login: Mon Jun 20 13:40:22 2011 from monkey2.local
root@systest-desktop:~#
The contents of the script is as follows:
#!/usr/local/bin/expect -f ## Connect to a neighboring linux box. spawn ssh nn.nn.nnn.nnn -l root expect "password:\n" send "mypassword\n" send "$expect_out(0,string)"
The script gets and displays the line requesting the password but times out. I've tried using "password:", "password: ", "password:\r" and password:*" but none seem to match.
The second issue is that the expect_out variable is not recognized and I get the following error when I run the script (whose name is 'this' and only has 11 lines!):
can't read "expect_out(0,string)": no such variable while executing "send "$expect_out(0,string)"" (file "this" line 18)