Re: Get command line output
| From: | Jason Wong | Date: | Wed, 22 Jan 2003 16:14:07 +0000 |
| Subject: | Re: Get command line output | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132624@lists.php.net to get a copy of this message | ||
On Thursday 23 January 2003 00:10, Greg Chagnon wrote:
> Does anyone know how to get certain parts of the output from an exec of a
> certain command? For example...if I run "w" I get this output:
>
> [root@Lunar]:~> w
> 11:02am up 56 days, 17:39, 1 user, load average: 0.07, 0.02, 0.00
> USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
> root pts/0 brpt-sh6-port214 11:01am 0.00s 0.27s 0.06s w
>
> Now what if I just want the infor on the 3rd line, and info about anyone
> else who is logged in, such as the username, the host, and the time without
> getting all the uptime and the header info? Thanks!
exec() 'returns' the output of the command in an array. Just extract from the
array whatever line(s) you need.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
You ain't learning nothing when you're talking.
*/