我正在写一个expect脚本,我需要为一个expect.Because传递多个发送命令,我希望所有的发送命令都是"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发布于 2013-09-01 20:27:03
看起来可能有点傻,但由于Set timeout是第一行代码,并且它的错误..,请检查Expect程序实际驻留在系统的/usr/bin/下的什么位置,并非所有的expect都在/usr/bin/expect下
有些人可能有机会将其放在/usr/local/bin/expect或任何地方
可能是如果你发布了完整的程序,检查你的shebang行,它应该以#开头。
发布于 2015-10-13 16:40:42
你不需要花括号。去掉它们就行了。
https://stackoverflow.com/questions/18523213
复制相似问题