[PHP] OT Regular Expression [grep]

2001-04-03 Thread Thomas Deliduka

I know this is off-topic but what I'm using it for will be in a PHP script!

All you who are grep-masters I have a question.

I would like to find all processes by a given user on a linux box and kill
them.  I know this much:

ps -u username 

Now, do I then pipe that to grep somehow and get just the PID's?

How can I do this quickly and easily?
-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] OT Regular Expression [grep]

2001-04-03 Thread Christian Reiniger

On Tuesday 03 April 2001 21:59, you wrote:

> I would like to find all processes by a given user on a linux box and
> kill them.  I know this much:
>
> ps -u username
>
> Now, do I then pipe that to grep somehow and get just the PID's?

(1) look up system / backtick operator / ... to get the output of the 
grep call as array, one line per entry

(2) do a

foreach ($TheOutput as $Line) {
  if (preg_match ('/^\s*(\d+)/', $Line, $Matches)) {
$PID = $Matches [1];
// kill it
  }
}

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

CPU not found. retry, abort, ignore?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] OT Regular Expression [grep]

2001-04-03 Thread Christian Reiniger

On Tuesday 03 April 2001 22:41, you wrote:
> (1) look up system / backtick operator / ... to get the output of the
> grep call as array, one line per entry

"... output of the ps call" of course

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

CPU not found. retry, abort, ignore?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] OT Regular Expression [grep]

2001-04-03 Thread Thomas Deliduka

Thanks!

On 4/3/2001 4:41 PM this was written:

> On Tuesday 03 April 2001 21:59, you wrote:
> 
>> I would like to find all processes by a given user on a linux box and
>> kill them.  I know this much:
>> 
>> ps -u username
>> 
>> Now, do I then pipe that to grep somehow and get just the PID's?
> 
> (1) look up system / backtick operator / ... to get the output of the
> grep call as array, one line per entry
> 
> (2) do a
> 
> foreach ($TheOutput as $Line) {
> if (preg_match ('/^\s*(\d+)/', $Line, $Matches)) {
>   $PID = $Matches [1];
>   // kill it
> }
> }

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]