LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2003, 01:12 AM   #1
hfawzy
Member
 
Registered: Aug 2002
Location: Egypt
Distribution: Debian Sarge, Slackware 10.0
Posts: 163

Rep: Reputation: 30
system function


Hello,
I am using the system() function to execute a shell command into my C program. But I want to check if the program given to the system() function is valid ,if not, I will print "not found" on the screen. So I want to do this by checking the exit code of the program executed. If the exit code equals 0, then, the program executed successfully, else, the program had errors when executing.
So ,how can I check an exit code of a program in C?
Thanks in advance.
 
Old 06-19-2003, 10:11 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
a quick look at the man page for system says that the value returned is the exit code of the program invoked. if you want to capture the programs i/o then you should look up popen or pipe, fork, and exec
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
system function exvor Programming 1 12-02-2005 03:34 PM
need help with system function in C program veereshai Programming 6 10-26-2004 03:20 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM
Perl system function syntax Crashed_Again Programming 2 03-20-2004 04:00 AM
system() function in nested if else/case! natalinasmpf Programming 10 01-26-2004 06:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration