Autoexpect挂起在脚本的末尾

时间:2016-01-25 16:53:07

标签: expect

我正在运行以下autoexpect脚本

    #!/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 -- "C4n4r1Wh4rf!!!\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

当我运行它时,似乎它没有正确终止并且我没有支持我的bash shell。只有当我按ctrl + c我才能得到我的终端

[...]
     0 output buffer failures, 0 output buffers swapped out
887VA#logout
Connection to 10.255.255.1 closed by remote host.
Connection to 10.255.255.1 closed.
root@blackbox:/etc/myscripts#
I don t have
my bahs
shell
^Croot@blackbox:/etc/myscripts#
-bash: I: command not found
root@blackbox:/etc/myscripts#

这对我来说是个问题,因为我需要在bash脚本中运行该脚本并将输出保存在txt文件中然后进行编辑

0 个答案:

没有答案