Created
March 28, 2011 16:02
-
-
Save dahernan/890721 to your computer and use it in GitHub Desktop.
Exec ssh command passing the password as a parameter
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
# set Variables | |
set password [lrange $argv 0 0] | |
set ipaddr [lrange $argv 1 1] | |
set scriptname [lrange $argv 2 2] | |
set arg1 [lrange $argv 3 c3] | |
set timeout -1 | |
# now connect to remote UNIX box (ipaddr) with given script to execute | |
spawn ssh root@$ipaddr $scriptname $arg1 | |
match_max 100000 | |
expect -timeout 4 "yes/no" {send "yes\r"} | |
# Look for passwod prompt | |
expect "password:" {send -- "$password\r"} | |
# send blank line (\r) to make sure we get back to gui | |
send -- "\r" | |
expect eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment