I have an EXPECT script that monitors the http pid's on an IBMIHS server:
....
send "ps -ef|grep htt|grep start|wc -l \r"
expect {
-re {.*(\d+).*} {
set theNum $expect_out(1,string)
}
}
puts "theNum = $theNum"
if {$theNum > 8} {
puts "it is ok"
} else {
puts "it is not ok"
}
....
The send "ps -ef|grep htt|grep start|wc -l \r" generates:
send: sending "ps -ef|grep htt|grep start|wc -l \r" to { exp5 }
Gate keeper glob pattern for '.(\d+).' is ''. Not usable, disabling the performance booster.expect: does "" (spawn_id exp5) match regular expression ".(\d+)."? (No Gate, RE only) gate=yes re=no
ps -ef|grep htt|grep start|wc -lexpect: does "ps -ef|grep htt|grep start|wc -l \r\n" (spawn_id exp5) match regular expression ".(\d+)."? (No Gate, RE only) gate=yes re=no
11expect: does "ps -ef|grep htt|grep start|wc -l \r\n11\r\n" (spawn_id exp5) match regular expression ".(\d+)."? (No Gate, RE only) gate=yes re=yes
expect: set expect_out(0,string) "ps -ef|grep htt|grep start|wc -l \r\n11\r\n"
expect: set expect_out(1,string) "1"
expect: set expect_out(spawn_id) "exp5" expect: set expect_out(buffer) "ps -ef|grep htt|grep start|wc -l \r\n11\r\n"
theNum = 1
it is not ok
The command line actually returns a number "11", but the (\d+) catches one '1' instead.
Your comments are appreciated in advance.