why no output from exec( $bad_command, $output, $status )?
| From: | greg keraunen | Date: | Thu, 15 Jun 2000 21:27:46 +0000 |
| Subject: | why no output from exec( $bad_command, $output, $status )? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-2004@lists.php.net to get a copy of this message | ||
Dear friends,
I have no problem getting the output from a simple command like 'ls' but
other commands do not always return their output successfully to php.
Does anyone understand why not or how to workaround this problem?
For example, if I try to exec an command that does not exist, I don't
get the error messages back from the shell.
$first_line = exec( 'command not found', $output, $status );
This problem is not limited to non-existent commands, but other
executables that return input from a terminal don't return output to
exec.
Example is java, xalan, etc.
SAMPLE CODE
$first_line = exec( 'command not found', $output, $status );
echo "$first_line<br>\n";
while (is_array($output) && (list($n,$line)=each($output))) {
echo "$n: $line<BR>\n";
}
if( $status ) echo "status = true";
OUTPUT:
status = true
Thanks for your insights.
--
greg keraunen <gkeraunen@valinux.com> 408-542-8600 x8085
web software engineer