hi
thanks for looking info this request, when i run this script
<?php $output = shell_exec('/usr/local/xpgk/bin/mp_shell.sh sh st 2>&1');
echo "<pre>$output</pre>"; ?>
i get this result
Mera VoIP Transit Softswitch ( 300 Advanced )
Release 2.1.8(Jun 23 2004 19:05:51)
---------------------- Common statistics ----------------------
Host : 205.150.74.182
Start time : 27/06/2005 17:53:58
Up time : 1 days 16 hours 45 minutes
Stat start time : 27/06/2005 17:53:58
Stat duration : 1 days 16 hours 45 minutes
Max load : 2 calls
Calls duration : 0 minute(s)
Active calls : 0
Active AVG 5 min : 0
Received calls : 33
Normal calls : 24
Failed calls : 9
Rejected calls : 0
Received Kb : 1750
Written Kb : 1739
wanted to know edit this and catch in for later use in tables>> here is added code i used but did not work
while(list($number,$value) = each($output)){
list($starttime,$maxload,$activecalls,$rejeted,)=split(', ',$value);
how to edit shell_exec output
Moderator: General Moderators
The result will likely be returned as a single string. If it gets returned like formatted just like you showed, then there are newline characters in that result that you can use to break up the output. From there, you can run any number of regular expression or string manipulation functions to find the info you want.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
break up the output - how to do this
can u let me know how break up the output
thanks
thanks
Look up explode(). If you're running on Linux, the newline character is
Code: Select all
\r\nReal programmers don't comment their code. If it was hard to write, it should be hard to understand.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Whoops... that's windowspickle wrote:Look up explode(). If you're running on Linux, the newline character isCode: Select all
\r\n
Just "\n" for *nix systems... the \r return character makes funny ^M's at the ends of the lines i think, like you transferred ascii in binary mode and you need dos2unix to mend it
Remember, these escaped characters only work in double quoted strings too
*Ahem*.... Congratulations - you passed my test! Ya - I was just testing you
I had a nagging feeling in the back of my head that I was giving the wrong endline character. Maybe I'll listen to those voices in my head a little more.
I had a nagging feeling in the back of my head that I was giving the wrong endline character. Maybe I'll listen to those voices in my head a little more.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.