Posted to tcl by meissa at Tue Oct 29 20:09:43 GMT 2024view pretty
#!/usr/bin/expect
set cmd [lrange $argv 2 end]
set timeout [lindex $argv 0]
set password [index $argv 1]
set timeout $timeout
eval spawn -noecho $cmd
log_user 0
expect {
-nocase -re "^.*password.*: " {
send "$password\r"
#log_user 1
exp_continue
}
timeout { exit 1 }
eof
}
catch wait result
puts [string range "$expect_out(buffer)" 2 end-2]
exit [lindex $result 3]