#!/usr/bin/expect -f
set username [lindex $argv 0]
set passwd [lindex $argv 1]
set destIP [lindex $argv 2]
set destDIR [lindex $argv 3]
set timeout 15
spawn ssh $username@$destIP
expect {
"(yes/no)?" { send "yes\n";exp_continue}
"*assword*" { send "$passwd\n";exp_continue }
"*assword*" { send "exit 1 \n" }
}
expect "#"
send "mkdir -p /tmp/testSendLog\n"
expect "#"
send "test -d $destDIR\n"
expect "#"
send "echo $? > /tmp/testSendLog/text.txt\n"
expect "#"
send "exit\r"
expect eof