When I run echo "passphrase" | expect expect.exp "hostname"
, everything works fine, but expect
exits immediately.
expect.exp
#!/usr/bin/expect
set passphrase [gets stdin]
set hostname [lindex $argv 0]
spawn ssh admin@$hostname
expect "passphrase"
send "$passphrase\r"
expect "admin@$hostname"
send "clear\r"
interact