Jump to content

Help on extracting specific data from Text


dima1236

Recommended Posts

Hi guys, i am php-newbie, i got a questions if i have : for example this in file or this is what i get return from a function how can i extract only the PID's to like Array or something?

i need to get only this numbers : 4739 4750 4755 4766 .

thanks in advance for help

 

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

USER      PID %CPU %MEM    VSZ  RSS TTY      STAT START  TIME COMMAND

test      4739  0.0  0.1  4692  1876 pts/0    S    23:43  0:00 -sh

test      4750  0.0  0.4  10236  5156 pts/0    S    23:43  0:00 Xvnc4 :2 -deskt

test      4755  0.0  0.1  4380  1560 pts/0    S    23:43  0:00 vncconfig -icon

test      4766  0.0  0.1  3716  1040 pts/0    R+  23:45  0:00 ps -ux

 

Link to comment
Share on other sites

i get an eror

Warning: file() expects parameter 1 to be string, array given in /var/www/test1.php on line 11

 

<?php
   include('SSH2.php');

   $ssh = new Net_SSH2('192.168.58.133');
   if (!$ssh->login('test', 'test')) {
       exit('Login Failed');
   }

   $pizza = ($ssh->exec('ps -ux'));
   $pieces = explode(" ", $pizza);
   $lines = file($pieces);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.