473,574 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Errors returned by System()functio n

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
http://fourcolorexplosion.com
Jul 17 '05 #1
1 2354
["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.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1559
by: praba kar | last post by:
Dear All, In Php If I send a command to system function then It will return 1 on success and 0 on failure. So based upon that value I can to further work. But In Python If I send a command to system function then It will return 0 only for both conditions(success and failure). So What I need to do for this. I want the result like php...
8
25208
by: Nick Li | last post by:
Hi, I am trying to writing a c program to send email using system() function call on Unix(Sun Solaris). I tried the following: #include <stdio.h> #include <stdio.h> int main(void) {
7
1750
by: Harsh_forC | last post by:
hello folks, when i'm using 'System' funtion in TC, perror function is outputting the following error msg..." Not enough memory" wat does it mean? how to get rid of this situaiton? plz help me out!
22
2812
by: SF | last post by:
Hello All, In a windows C learning project I am wokring on I use the system function to run a command, I want to suck the results into a vairable. The system function seems to only return an int. I would like to know how could this is done? I can see only one way currently and I know that there must be a better method. Right now I would be...
16
2135
by: BHARAT MEHTA | last post by:
Hi Guys, I am little new to C. I wish to know the way to use the 'system' function. I mean I know that the function is used to run an external DOS command but every time I use it it returns -1 which meansthe command could not be executed. Kindly help me............
8
3192
by: bob | last post by:
Which is faster - a call to a system function or a call to a library function?
2
2410
by: nnandini8 | last post by:
Hello Guys, I have a doubt in system() function. I need to implement the certain command line arguements in a program. For Example if I type "dnaml" at command line and press enter then it will ask me to enter 'Y' and if I press enter it will generate some files. So here I used system("dnaml")
3
2455
by: extrnh | last post by:
i have a c++ program compiled in visual c++ that links to a c library. when a system function is called in the c library a blank command window is displayed while the c logic is executing. this is from the windows cmd.exe that is executed by the system function. i need to prevent the window from being displayed and would prefer doing so...
0
1977
by: rajarora | last post by:
Hi , Is there anybody who have any idea of any System Function in C/C++ for Sun-Solaris (unix) platform which can serve the alternative of execl() system function. Actually I am calling a fork-execl() pair and then making an interprocess communication between these two(parent-child process). But the problem is that somewhere in exec()...
0
7755
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8097
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6504
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3770
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3791
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2268
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1097
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.