By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,342 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,342 IT Pros & Developers. It's quick & easy.

Capture the return status from a shell script using system call

P: 2
Hi,

I am calling a unix script from my c program, but i need to capture the return value of the script. The system() function would return whether the script was successfully executed or not. But the return value of the script is needed within the C program.

Please help me out here.

Thanks and Regards,
Nav
Mar 4 '11 #1
Share this Question
Share on Google+
3 Replies

weaknessforcats
Expert Mod 5K+
P: 9,197
You might try creating a file in your C program and then use that file as the return from your program to the script.
Mar 7 '11 #2

P: 2
I have thought about that, but I can consider it as the last resort. Is there any other way of finding out the return status of the script from a c program? Any other function?
Mar 9 '11 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
Not that I know of. Your C program must leave a mark somewhere the script can find it. The return from main() is used (or maybe not used( by the OS and therefore may not be passed on to your script.
Mar 12 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.