linux - spawn_id : spawn id exp6 not open

标签 linux shell scripting expect

我知道这里已经提到了这个问题,但该解决方案对我不起作用。

我有这个脚本(我们将其命名为 myscript.sh),它在远程环境中生成一个进程并且应该与之交互。

#!/usr/bin/expect
log_user 0
set timeout 10
spawn ssh -o PubkeyAuthentication=no [lindex $argv 0] -n [lindex $argv 1]
expect "password:" {send "mypassword\r"}
expect "Continue to run (y/n)" {send "n\r"}
interact

当我在本地环境中调用这个脚本时...

myscript.sh user@host "command1;./command2 parameter1 parameter2"

我在第 7 行(交互)收到上述错误

有什么想法吗??

最佳答案

我怀疑 expect 无法找出(匹配)您发送的模式。

expect "password:" {send "mypassword\r"}
expect "Continue to run (y/n)" {send "n\r"}

再次检查“password:”和“Continue to run (y/n)”是否大写正确。

如果仍然出现相同的错误,您可以尝试使用正则表达式。

关于linux - spawn_id : spawn id exp6 not open,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7490634/

相关文章:

linux - 为什么 "export"在运行时设置 linux shell 环境变量的 linux system() 命令中不起作用?

linux - AWS 负载均衡器将 Wordpress URL 强制指向特定实例

linux - 删除每行末尾的 ';'

arrays - 如何从 bash 函数返回数组

linux - 定义每次使用时要评估的 bash 变量

sql-server - 在 SQL Server 中,如何为给定表生成 CREATE TABLE 语句?

linux - 行尾处的 Vi 编辑和光标位置?

linux - shell 脚本 - 需要根据上面的输出将邮件发送到特定的 id

bash - 在一行上打印 shell 环境函数

unix - 如何从 unix 中的 cut 命令的结果中提取子字符串?