Currently, I am working on a script to automatize a process, in this point my script is short and simple but I have had some Issues with expect/send
.
code:
#!/usr/bin/expect -f
#!/bin/bash
set ip ***
set ip2 ***
set user ***
set usr2 ***
set OTP [lindex $argv 0]
spawn ssh "usr@$ip";
expect "OTP Password:"
send -- "$OTP"
interact
expect "prompt >"
send -- "ssh usr2@$ip2"
interact
For this point script works until the first ssh but... for the second ssh (expect "prompt >" / send -- "ssh $ip2"
) It doesn't work... I don't get the idea why. I have tried with some commands like expect eof
, wait
, timeout
and nothing as well I checked to expect version is on latest (5.45).
Do you have any idea? thanks!