我正在尝试在期望脚本中运行expect脚本(下面的代码)。但是,我收到以下错误:
spawn ./script.exp
couldn't execute "./script.exp": no such file or directory
while executing
"spawn "./script.exp""
(file "./script.exp" line 7)
我已经双重检查并且script.exp存在并且位于/ home / user / scripts目录中。
#!/usr/bin/expect
spawn ssh user@192.168.2.1
expect "$"
send "cd /home/user/scripts\r"
expect "$"
spawn "./script.exp"
expect "$"
send "logout\r"
答案 0 :(得分:0)
按照上面给出的建议,使用send "./script.exp\r"
而不是spawn "./script.exp"
,解决问题。