Skip to content

Instantly share code, notes, and snippets.

@shaon
Created January 8, 2013 12:09
Show Gist options
  • Save shaon/6dc04ab0acba9a788a3f to your computer and use it in GitHub Desktop.
Save shaon/6dc04ab0acba9a788a3f to your computer and use it in GitHub Desktop.
simple Expect script to ssh to another machine.
#!/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 "reb00t\r" }
expect "# "
send "$cmd\r"
expect "# "
send "ls\r"
expect "# "
##send "exit\r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment