Last active
August 30, 2016 02:16
-
-
Save wangmuy/5b13b2de587e60554583e3e8d0c80dc1 to your computer and use it in GitHub Desktop.
sshpass supply password in commandline
This file contains 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/expect -f | |
# http://stackoverflow.com/questions/28051969/tcl-expect-equivalent-of-bash-or-how-to-pass-arguments-to-spawned-process-in | |
# usage: | |
# sshpass.sh userpwd ssh [email protected] 'nohup sleep 30 </dev/null >/dev/null 2>&1 &' | |
# sshpass.sh userpwd scp svn-auth-file.bak [email protected]:/home/user/svn-auth-file.bak | |
set PWD [lindex $argv 0] | |
set ARGS [lrange $argv 1 end] | |
spawn {*}$ARGS | |
expect "*password:*" | |
send "$PWD\r" | |
expect eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment