如何避免与发送到生成进程的数据匹配
在我的期望脚本中,以下代码示例给我带来了很多麻烦
#!/usr/bin/expect
#some other code
set psucommand "psu |grep -v grep | grep $jobname\r"
#some other code
expect "env[lindex $argv 0]>" {send $psucommand}
expect {
"$jobname" {
send_user "$jobname"
send "exit\r"}
"env[lindex $argv 0]>" {
send_user ""
send "exit\r"}
}
第二个“期望”正在尝试(成功)匹配实际的 $psucommand (psu |grep -v grep | grep ACTUALJOBNAME\r) 我发送到生成的进程,我只需要匹配生成的进程的输出。
这是当我使用 Expect -d 运行此脚本时我在接近尾声时看到的内容,
expect: does " psu |grep -v grep | grep ACTUALJOBNAME\r\n" (spawn_id exp6) match glob pattern "ACTUALJOBNAME"? yes
它与我发送到生成进程的命令相匹配。我需要避免这种情况。
帮助!
In my expect script following code sample is making me a lot of troubles
#!/usr/bin/expect
#some other code
set psucommand "psu |grep -v grep | grep $jobname\r"
#some other code
expect "env[lindex $argv 0]>" {send $psucommand}
expect {
"$jobname" {
send_user "$jobname"
send "exit\r"}
"env[lindex $argv 0]>" {
send_user ""
send "exit\r"}
}
This second "expect" is trying (successfully) to match the actual $psucommand (psu |grep -v grep | grep ACTUALJOBNAME\r) I send to the spawned process, and I need only the spawned process's output to be matched.
Here's what I see near the end when I run this script with expect -d
expect: does " psu |grep -v grep | grep ACTUALJOBNAME\r\n" (spawn_id exp6) match glob pattern "ACTUALJOBNAME"? yes
It's matching my command I sent to the spawned process. I need to avoid this.
Help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这导致 psucommand 为
psu | grep [A]CTUALJOBNAME
因此,您需要
发送“$psucommand\r”
,但期望 $jobname 不应拾取该命令。This results in psucommand being
psu | grep [A]CTUALJOBNAME
So, you need to
send "$psucommand\r"
but expecting on $jobname should not pickup the command.