Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP return_var codes?

Tags:

I'm testing the php exec command:

http://php.net/exec

and I'm getting back a result code of 127.

My php code is:

<?  print "<br>executing 'hello':<br><b>"; exec ("hello", $output, $result); var_dump($output); print "<br>$result"; print "<br></b>end hello.";   print "<br><hr><br>";   print "<br>executing 'dir':<br><b>"; exec("dir", $output2, $result2); var_dump($output2); print "<br>$result2"; print "<br></b>end dir.";  ?> 

And the output is:

executing 'hello': array(0) { }  127 end hello.   executing 'dir': array(2) { [0]=> string(42) "bs1.jpg hello  index.htm ml1_1.jpg pp1.jpg" }  0 end dir. 

The php documentation (as far as I could find) says this:

return_var

If the return_var argument is present along with the output argument, then the return status of the executed command will be written to this variable.

...but does not have a list of output possibilities or a way to look them up.

Any suggestions?

like image 532
Jeffrey Berthiaume Avatar asked Feb 09 '10 16:02

Jeffrey Berthiaume


2 Answers

Return codes can be a bit arbitrary. Basically though, any non-zero return value is an error. Here's a list of some common ones, but typically, unless you're working with a specific program, it's easier to just assume non-zero = some error was found, as opposed to trying to map a number of different programs to specific error codes.

like image 119
Owen Avatar answered Oct 05 '22 08:10

Owen


Return code 127 means The specified procedure could not be found.

Assuming you are on Windows, Windows System Error Codes

like image 24
Anthony Forloney Avatar answered Oct 05 '22 08:10

Anthony Forloney