Errors returned by System()function

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm attempting to debug some code that uses the System function.  When the
function is called, it returns Error 1.  Does anyone know what that error
might be, or where I can find a list of error codes for the function?

Any help is most appreciated.

Randy Jackson

Re: Errors returned by System()function

["Followup-To:" header set to comp.lang.php.]
Randy Jackson wrote:
Quoted text here. Click to load it

The System() function returns a string!

If you mean it returns the string "Error 1", that means it executed the
specified command succesfully and /that/ command (whatever it was)
produced an output for which the last line was "Error 1".

If, on the other hand, you mean that the System() call returned false
(indicating a failure of the specified command) and that the second
parameter is 1 after the call, then it is the command you call within
the System() function that has the responsability for that.

For example ('echo $?' prints the exit status of the last command):

    php$ nocommand
    bash: nocommand: command not found
    php$ echo $?

Seems that bash exits with a exit code of 1 when it can't find the

    php$ wget
               => `index.html.1'
    Resolving failed: Host not found.
    php$ echo $?

Seems that wget exits with a exit code of 1 when it can't resolve the
domain part of the URL

    php$ calc 78 + 3
    php$ echo $?

Seems that calc exits with a exit code of 0 when it works properly (as
do most (all?) other programs)

Mail sent to my "From:" address is publicly readable at /
== ** ## !!                                                         !! ## ** ==
bypass the spam filter. I will answer all pertinent mails from a valid address.

Site Timeline