Simple expect ssh example
#!/usr/bin/expect
set timeout 1
set cmd {uname -a}
spawn ssh root@$argv
expect_after eof { exit 0 }
## interact with SSH
expect "yes/no" { send "yes\r" }
expect "password:" { send "rootpasswd\r" }
expect "# "
send "$cmd\r"
expect "$cmd\r"
expect "(.*)\r"
send "exit\r
No comments:
Post a Comment