[PHP] storing the passthru() output as an array

2003-10-06 Thread Michael P. Carel
Hi again,

Have another problem here I need to get the output of this syntax

$ps = (passthru(ps -ef));

and store it in an array line by line, I specifically want to get the
Columns of the PID for this command and store it in a selection box .

Any Idea how, thanks in advance.


Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] storing the passthru() output as an array

2003-10-06 Thread Brad Pauly
On Mon, 2003-10-06 at 19:41, Michael P. Carel wrote:
 Hi again,
 
 Have another problem here I need to get the output of this syntax
 
 $ps = (passthru(ps -ef));
 
 and store it in an array line by line, I specifically want to get the
 Columns of the PID for this command and store it in a selection box .
 
 Any Idea how, thanks in advance.

You can use output buffering to grab the output and explode to put the
lines in an array.

http://us4.php.net/manual/en/ref.outcontrol.php

ob_start();
passthru(ps -ef);
$ps = ob_get_contents();
ob_end_clean();

$lines = explode(\n,$ps);

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] storing the passthru() output as an array

2003-10-06 Thread Chris Kay

I don't know if this is the easiest way but a solution

Pipe ps -ef to a file read the file into an array and do with it what
you will.

EG

$filename = /tmp/psefdump.txt;
exec(ps -ef  $filename);

$lines = file($filename);

foreach ( $lines as $var ) {
// Yadda Yadda
}

Hope this helps...

--
Chris Kay (CK)
Eleet Internet Services
M: 0415 451 372
P: 02 4620 5076
F: 02 4620 7008
E: [EMAIL PROTECTED]


-Original Message-
From: Michael P. Carel [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 7 October 2003 11:41 AM
To: [EMAIL PROTECTED]
Subject: [PHP] storing the passthru() output as an array


Hi again,

Have another problem here I need to get the output of this syntax

$ps = (passthru(ps -ef));

and store it in an array line by line, I specifically want to get the
Columns of the PID for this command and store it in a selection box .

Any Idea how, thanks in advance.


Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] storing the passthru() output as an array

2003-10-06 Thread David Otton
On Tue, 7 Oct 2003 09:41:03 +0800, you wrote:

Have another problem here I need to get the output of this syntax

$ps = (passthru(ps -ef));

and store it in an array line by line,

Turn on output buffering, grab the output of your script, then turn it off.
(ob_start, ob_get_contents, ob_end_clean)

But that's a hack; you're better off using shell_exec instead of passthru

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] storing the passthru() output as an array

2003-10-06 Thread Michael P. Carel
Thanks it works.

 On Mon, 2003-10-06 at 19:41, Michael P. Carel wrote:
  Hi again,
  
  Have another problem here I need to get the output of this syntax
  
  $ps = (passthru(ps -ef));
  
  and store it in an array line by line, I specifically want to get the
  Columns of the PID for this command and store it in a selection box .
  
  Any Idea how, thanks in advance.
 
 You can use output buffering to grab the output and explode to put the
 lines in an array.
 
 http://us4.php.net/manual/en/ref.outcontrol.php
 
 ob_start();
 passthru(ps -ef);
 $ps = ob_get_contents();
 ob_end_clean();
 
 $lines = explode(\n,$ps);
 
 - Brad
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php