I have write a script which contains
ssh -p 12345 dcplatform@10.125.42.50
ssh 127.0.0.1 -p 5555 "$CMD"
ssh root@$GUEST_IP "$CMD"
before I use public key, it works well, now I want to change to "expect", BUT I don't want to change above code and "parameter position"
I can post a expect template can some one help me to modify it
#cat sshx
#!/usr/bin/expect
set timeout 60
set host [lindex $argv 0]
set name root
set password root
spawn ssh $host -l $name
expect {
"(yes/no)?" {
send "yes\n"
expect "assword:"
send "$password\n"
}
"assword:" {
send "$password\n"
}
}
send "uname -a\n"
#send "exit\r"
expect eof
exit
sshx -p 12345 dcplatform@10.125.42.50
sshx 127.0.0.1 -p 5555 "$CMD"
sshx root@$GUEST_IP "$CMD"
To goal is
Above cmd will not need to input password, I can't use public keys now, becasue I remote filesystem is readonly
Lei