spawn_id:spawn id exp6未打开 [英] spawn_id: spawn id exp6 not open

查看:2208
本文介绍了spawn_id:spawn id exp6未打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I know that this issue is already mentioned here, but the solution does not work for me.

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

I have this script (let's name it myscript.sh) that spawns a process on remote environment and that should interact with it.

#!/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

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

When I call this script on local environment...

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

我在第7行(互动)遇到上述错误

I get the above error at line 7 (interact)

任何想法?

推荐答案

我怀疑期望值无法找到(匹配)您发送的模式.

I suspect the expect is not able to find out(matching) the pattern you are sending.

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

再次检查密码:"和继续运行(y/n)"是否正确使用了大写字母.

Check out again whether the "password:" and "Continue to run (y/n)" are in correct CAPS.

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

If still getting the same error, you can try using regular expression.

这篇关于spawn_id:spawn id exp6未打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆