galfrid
11-18-2009, 08:09 PM
So I'm stuck. I've been trying to get a randomized motd on my site, and I don't really want to do the work of thinking up my own messages. I've found a decent little generator for the purpose (for those of you familiar with ubuntu, it's called Fortune), and made sure it will output to the shell.
Now, when I try to capture its output with php and print/echo it to the page, I get either a blank screen or an empty array - using shell_exec(), exec(), or system() . I know these commands work - I've tested using
<?
$output = shell_exec('ls');
echo $output;
?>
which outputs the contents of the directory quite happily.
So my questions are:
Is it possible that these commands won't work with fortune because of potential multi-line output?
Do I need to use the output buffer (ob_start) or some other function to actually display the output of the command?
Any help here would be just awesome.
Now, when I try to capture its output with php and print/echo it to the page, I get either a blank screen or an empty array - using shell_exec(), exec(), or system() . I know these commands work - I've tested using
<?
$output = shell_exec('ls');
echo $output;
?>
which outputs the contents of the directory quite happily.
So my questions are:
Is it possible that these commands won't work with fortune because of potential multi-line output?
Do I need to use the output buffer (ob_start) or some other function to actually display the output of the command?
Any help here would be just awesome.