#!/usr/bin/expect
if {$argc!=2} {
send_user "usage: ./expect ssh_user password/n"
exit
}
foreach i {11 12} {
set timeout 30
set ssh_user [lindex $argv 0]
set password [lindex $argv 1]
spawn ssh -i .ssh/$ssh_user
[email protected]expect_before "no)?" {
send "yes/r" }
sleep 1
expect "Enter passphrase for key*"
send "password/r"
expect "*#"
send "echo hello expect! > /tmp/expect.txt/r"
expect "*#"
send "echo/r"
}
exit