nero0102
10-09-2004, 01:49 AM
can you capture a programs output and display it on a web page in php?
Just today I saw that
<?php
$output = shell_exec('who -b | cut -c25-');
echo "Server's last reboot: $output";
?>
would output the servers last reboot time, by executing the command in ()'s.
(was looking at my admin's .profile for how he got unix to spit out all the Hi blah blah, its blah blah time stuff when I logged in)
I thought this was super slick since I had been trying to do this for awhile in CGI/Perl.
Since the thing I want to do is a compiled program (using gcc to compile a .c file) would I have to pipe its output to a file and then use the shell_exec to print the contents of the file?
Also, is the php manual good for learning from, or a good resource?
The one book I have that mentions php only has one chapter, and Im too poor to buy any more books this semester :p
I guess I could go through my directories and remake everything in php for starters.
Just today I saw that
<?php
$output = shell_exec('who -b | cut -c25-');
echo "Server's last reboot: $output";
?>
would output the servers last reboot time, by executing the command in ()'s.
(was looking at my admin's .profile for how he got unix to spit out all the Hi blah blah, its blah blah time stuff when I logged in)
I thought this was super slick since I had been trying to do this for awhile in CGI/Perl.
Since the thing I want to do is a compiled program (using gcc to compile a .c file) would I have to pipe its output to a file and then use the shell_exec to print the contents of the file?
Also, is the php manual good for learning from, or a good resource?
The one book I have that mentions php only has one chapter, and Im too poor to buy any more books this semester :p
I guess I could go through my directories and remake everything in php for starters.