Skip to content

Instantly share code, notes, and snippets.

@amashigeseiji
Last active August 29, 2015 14:08
Show Gist options
  • Save amashigeseiji/8840effa4e523f089739 to your computer and use it in GitHub Desktop.
Save amashigeseiji/8840effa4e523f089739 to your computer and use it in GitHub Desktop.
send command to remote server over ssh
#!/usr/bin/expect
set timeout 10
spawn ssh [lindex $argv 0]
expect {
"Last login" {
send [lrange $argv 1 $argc]\n
send exit\n
}
timeout {
send_user "connection is timeout.\n"
exit
}
}
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment