This will pull out the lines (I am making sure batch is running) the
instance names above:
set result [exec ps -ef | grep batch | grep -v grep]
I need to parse the $result and see which ones are not showing up now.
Would this be a regex or something like a string scan?
Robert
> set result [exec ps -ef | grep batch | grep -v grep]
I think that will not work. exec does not allow pipes, only arguments.
You will need something like: set result [open "| ps -ef | grep batch | grep
-v grep"].
Arnulf
Oh no, exec does allow pipes. I use that all the time.
Robert
[exec] allows pipes just fine.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
regexp would work fine, string match would also work,
string first is probably easiest.
foreach word {DEV1 TST1 PRO1} {
if {[string first $word $result] < 0} {
puts "$word is NOT in results!"
}
}
Bruce
Instead of grep -v grep, you could use awk to print only the program
name (it is always field 8 (?)), and then set an array with the
result:
set result [exec ps -ef | awk {/batch/ && !/grep/ {print $8}}]
foreach prog [split $result "\n"] {
set found($prog)
}
Now check the array for the missing:
set missing [list]
foreach required {DEV1 TST1 PRO1} {
if {![info exists found($required)]} {
lappend missing $required
}
}
puts "MISSING: $missing"
R'
Is "< 0" right there?
Robert
Yes, [string first ...] returns the index where the substring is found,
so zero or positive number means the workd was found somewhere, < 0
(specifically -1) means not found.
Bruce
Ah, I did not know that.
Robert
Yes, you are right. I had a different problem when just cut and pasting.
My fault.
Arnulf
> Arnulf Wiedemann wrote:
>> Robert Hicks wrote:
>>
>>> set result [exec ps -ef | grep batch | grep -v grep]
>> I think that will not work. exec does not allow pipes, only arguments.
>
> [exec] allows pipes just fine.
>
You are right. See my other posting in this thread
Arnulf.