|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8652 exec and system always return -1
Submitted: 2001-01-11 07:31 UTC Modified: 2001-05-11 21:11 UTC
From: simon dot king at pipinghotnetworks dot com Assigned:
Status: Closed Package: Program Execution
PHP Version: 4.0.4 OS: RedHat Linux 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
29 + 36 = ?
Subscribe to this entry?

 [2001-01-11 07:31 UTC] simon dot king at pipinghotnetworks dot com

function run_command($command, $errmsg) {
  $lastline = exec("$command 2>&1", &$lines, $rc);
  if ($rc) {
    print("Command  : $command\nReturned : $rc\nOutput\n------\n");
    print(join("\n", $lines)."\n\n");

$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 but this does not seem like a packaging error, so I am reporting it here.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-15 08:45 UTC]
duplicate of #8466
 [2001-05-11 21:11 UTC]
Fixed in CVs.


PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 21 12:01:29 2024 UTC