I need to run remote apps via ssh. Easily done. However I'm trying to automate this, and despite 15+ years in unix, I've never used expect before
(just sh/ksh and some perl)
#!/usr/bin/expect
#
# for now, assume called with [host] [user] [passwd]
spawn /usr/bin/ssh [lindex $argv 0] -l [lindex $argv 1]
expect {*password:}
send "[lindex $argv 2]\r"
#
send "<command>\r"
#
expect {*home*} exit
My problem is that the target systems might have either of two password. I need to write expect that will try the first passwd, and if denied, try the second, but so far I've been unsuccessful, and really been struggling with expect syntax (I know ... it's like tkl - sorry I've been avoiding that one too
Thanks in advance ... phil
#!/usr/bin/expect
#
# for now, assume called with [host] [user] [passwd]
spawn /usr/bin/ssh [lindex $argv 0] -l [lindex $argv 1]
expect {*password:}
send "[lindex $argv 2]\r"
#
send "<command>\r"
#
expect {*home*} exit
My problem is that the target systems might have either of two password. I need to write expect that will try the first passwd, and if denied, try the second, but so far I've been unsuccessful, and really been struggling with expect syntax (I know ... it's like tkl - sorry I've been avoiding that one too
Thanks in advance ... phil