chris.zeman Posted August 11, 2006 Share Posted August 11, 2006 I am using the system command, as shown below, to display system information on my web page.[code]<?php system("free -m"); ?>[/code]I'd like to parse the output and generate my own tables, but haven't been able to find any information on how to do it. Is it possible to do this in PHP?Thanks,Chris Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 11, 2006 Share Posted August 11, 2006 could probably use output buffering. look up ob_start() and ob_end_get(); or something similar. essentially captures output and lets you do with it as you please once you cease capturing it. Quote Link to comment Share on other sites More sharing options...
longree Posted August 11, 2006 Share Posted August 11, 2006 Simple Solution:[code]<?php $cmd = system("free -m"); echo"$cmd";?>[/code]Edit[Sorry, didn't see you wanted to put it into tables... hmm... i'll come back on this one...] Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 11, 2006 Share Posted August 11, 2006 it's not just that he wants it put into tables, but the system() function only returns the LAST LINE of the command's output. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted August 11, 2006 Share Posted August 11, 2006 what if you used 'free -m > system.txt' to pipe the command thru to a temporary text file?Then you can read the file back in and will contain the whole output of the command..not sure if this works but worth a shot?RegardsLiam Quote Link to comment Share on other sites More sharing options...
effigy Posted August 11, 2006 Share Posted August 11, 2006 [tt]exec($command, $output, $return_value);[/tt] What does the output look like? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.