Created
October 2, 2013 19:09
-
-
Save briansorahan/6798949 to your computer and use it in GitHub Desktop.
Expect script to execute commands over ssh. e.g.
$ rsudo [email protected] mypassword cat /etc/passwd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env expect | |
set login [lindex $argv 0] | |
set password [lindex $argv 1] | |
set cmd [lrange $argv 2 end] | |
spawn ssh $login | |
expect { | |
"assword:" { | |
send "$password\r" | |
} | |
} | |
expect { | |
"# " { | |
send "$cmd\r" | |
} | |
} | |
expect "# " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment