0

我正在编写一个期望脚本,我必须为一个期望传递多个发送命令。因为我期待所有发送命令都“OK”。

#!/usr/bin/expect
{

set timeout 5

spawn ssh .......

expect "OK"

send "set connections 10\r"

send "INCR connections\r"

send "INCR connections\r"

send "INCR connections\r"

expect eof

}

这会引发以下错误

invalid command name "
set timeout 5

spawn .......
expect "OK"
send "set connections 10\r"

send "INCR connections\r"


expect eof
"
    while executing
"{
set timeout 5
4

2 回答 2

0

可能看起来很傻,但是因为Set timeout第一行代码和它的错误..,请检查您的 Expect 程序实际驻留在系统上 /usr/bin/ 下的位置 不是所有的都在 /usr/bin/expect 下有他们的期望

有些人可能有机会将它放在 /usr/local/bin/expect 或任何地方

可能是如果您完全发布程序,请检查您的 shebang 行,它应该以 # 开头

于 2013-09-01T12:27:02.860 回答
0

你不需要花括号。只需删除它们。

于 2015-10-13T08:40:42.350 回答