#!/usr/bin/expect -f
# USAGE:
#----------------------------------------------------
# ./ssh-expect.exp
#----------------------------------------------------
# set Variables
set password [lrange $argv 0 0]
set remote_ipaddr [lrange $argv 1 1]
set scriptname [lrange $argv 2 2]
set arg1 [lrange $argv 3 3]
set timeout -1
spawn ssh root@$remote_ipaddr $scriptname $arg1
match_max 100000
# Look for passwod prompt
expect "*?assword:*"
# Send password to the remote machine
send -- "$password\r"
send -- "\r"
#terminate the connection
expect eof
No comments:
Post a Comment