> [EMAIL PROTECTED] said:

> Basically, what I want to do here is catch the output from ps. The ultimate
> goal is to find processes meeting certain criteria (not yet detailed) and
> kill them.

ps output varies by OS and depends on the flags you give it.  Also I have 
found some fields are empty and fields are fixed sized, sometimes without 
whitespace between the fields.  Given the fields are fixed length, you can do 
something like this with a regex and pick out the fixed size fields:

/(.{5})({.{8})/;

$field1 = $1;  # 5 characters wide
$field2 = $2;  # 8 characcters wide

See the perlre man page for details on the {n} notation.

You may have to delete leading and trailing whitespace with this method.  And 
the field size is heavily dependent on what version of ps you use.  Some 
versions of ps support user defined format.  So you might take a look at using 
that, if the code is not intended to be portable across OS versions.

-- 
Smoot Carl-Mitchell
Consultant



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to