Using two interact in a Expect script Using two interact in a Expect script linux linux

Using two interact in a Expect script


I have resolved the problem:

#!/usr/bin/expectset timeout -1set arg1 [lindex $argv 0]spawn ssh -p 24 my_username@my_linux.domain.comexpect "#"send "go $arg1 \n"expect "sername:"send "my_username\n"expect "assword:"send "my_password\n"expect "#"interact timeout 5 returnsend "\n"expect "root@my_linux:~#"send "exit\n exit\n"interact

Explanation: I added a few lines:

# This prevents commands from timing out (default timeout is 10 seconds).set timeout -1# When I type something, the timeout is ignored, but when I'm not typing,# it waits 5 seconds and then continues.interact timeout 5 returnsend "\n"expect "root@my_linux:~#"send "exit\n exit\n"