PHP 4.0 Bug #8652: exec and system always return -1
| From: | simon dot king at pipinghotnetworks dot com | Date: | Thu, 11 Jan 2001 12:31:37 +0000 |
| Subject: | PHP 4.0 Bug #8652: exec and system always return -1 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-43771@lists.php.net to get a copy of this message | ||
From: simon.king@pipinghotnetworks.com
Operating system: RedHat Linux 6.2
PHP version: 4.0.4
PHP Bug Type: Program Execution
Bug description: exec and system always return -1
<?
function run_command($command, $errmsg) {
$lastline = exec("$command 2>&1", &$lines, $rc);
if ($rc) {
print("<pre>\n");
print("$errmsg\n\n");
print("Command : $command\nReturned : $rc\nOutput\n------\n");
print(join("\n", $lines)."\n\n");
}
return($rc);
}
$rc = run_command("/bin/uname -a", "Uname Failed!");
print("rc now = $rc");
?>
All the commands that I have tested (uname is just an example) have returned -1 as the return code,
even though the command has executed perfectly well. I get the same error if I use system instead of
exec. I cannot see how else to run a command and check to see whether it failed or not.
I am using PHP RPMS downloaded from http://rpms.arvin.dk/php/ but this does not seem like a
packaging error, so I am reporting it here.
--
Edit Bug report at: http://bugs.php.net/?id=8652&edit=1