Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Autoexpect hangs at the end of the script

$
0
0

I have an autoexpect script. I modified it and it works great, however when it finish to run it hangs and I need to do ctrl+C in order to get my terminal

[..]
887VA#logout
Connection to 10.255.255.1 closed by remote host.
Connection to 10.255.255.1 closed.
root@blackbox:/etc/myscripts#

^Croot@blackbox:/etc/myscripts# ^C
root@blackbox:/etc/myscripts#

In the blank space above I pressed enter many times

Code

#!/usr/bin/expect -f

set force_conservative 0  ;# set to 1 to force conservative mode even if
                          ;# script wasn't run conservatively originally
if {$force_conservative} {
        set send_slow {1 .1}
        proc send {ignore arg} {
                sleep .1
                exp_send -s -- $arg
        }
}

set timeout -1
spawn $env(SHELL)
match_max 100000


send -- "ssh f.olivieri@10.255.255.1\r"
expect -exact "Password: "
send -- "passwordhere!!!\r"
expect -exact "887VA#"
send -- "show interface vlan 2\r"
expect -exact "Vlan2 is up, line protocol is up \r"
send -- "logout\r"
expect eof

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>