Re: Errors returned by System()function
From: Pedro Graca (hexkid_at_dodgeit.com)
Date: 11/18/04
- Next message: Andy Jacobs: "Re: PHP Upload ! Storing Image data in MySQL"
- Previous message: Pedro Graca: "Re: Round and Ceil problem"
- In reply to: Randy Jackson: "Errors returned by System()function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Nov 2004 22:17:05 GMT
["Followup-To:" header set to comp.lang.php.]
Randy Jackson wrote:
> 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?
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 $?
127
Seems that bash exits with a exit code of 1 when it can't find the
command
php$ wget http://www.baddomain.net/index.html
--21:57:02-- http://www.baddomain.net/index.html
=> `index.html.1'
Resolving www.baddomainhere.net... failed: Host not found.
php$ echo $?
1
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
81
php$ echo $?
0
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 http://www.dodgeit.com/ == ** ## !! !! ## ** == TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may bypass the spam filter. I will answer all pertinent mails from a valid address.
- Next message: Andy Jacobs: "Re: PHP Upload ! Storing Image data in MySQL"
- Previous message: Pedro Graca: "Re: Round and Ceil problem"
- In reply to: Randy Jackson: "Errors returned by System()function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|