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!
This results in psucommand being
psu | grep [A]CTUALJOBNAMESo, you need to
send "$psucommand\r"but expecting on $jobname should not pickup the command.