Simple EXPECT script to execute remote command and displat output

Posted by s.mihai on Server Fault See other posts from Server Fault or by s.mihai
Published on 2011-01-13T20:54:25Z Indexed on 2011/01/13 21:55 UTC
Read the original article Hit count: 281

Filed under:
|

I am trying to connect to a network router and execute show status on it.
Currently i am using:
spawn ssh -o StrictHostKeyChecking=no [email protected]
expect " * ? password:*\r"
send -- "secretPassword\r"
sleep 5
send -- "show status\r"
sleep 10
send -- "exit\r"

It dosen't work, i get stuck at [email protected]'s password:i've tried entering the password but it does not work, i get:
server1:~# secretPassword
-bash: server1: command not found
server1:~#


What am i doing so wrong here ... ?

© Server Fault or respective owner

Related posts about ssh

Related posts about expect