1. Making sure script executes (called from c program)
/ I'm using the system() call to fire off some shell scripts in an automated
/ process (Under Solaris 2.6 and gcc). How can I tell if the process fired off
/ or if there were errors (e.g. the script called doesn't exist in the
/ directory?). I've looked at the exec***() series of function calls as well,
/ but the man pages are cryptic.
system() should return a nonzero value of the call failed, zero if the
command completed okay. You'll have to delve into the details of system()
and wait() to understand the return value.
/ [sounds vaguely like fork()ing in my mind].
The overall design is
create pipes as needed to replace stdin, stdout, stderr, and/or others
fork
child
close stdin, ... as needed
dup pipes to stdin, ...
close original of dup files
close the parent side of the pipes
do anything else you need with the environment
exec the new program
parent
close the child side of the pipes
optionally fdopen pipes into FILE*
read and/or write the pipes
wait for the child to complete
/ Am I totally wrong in trying to use either of these two functions to
call shell
/ scripts and being able to expect to find out what happened? If so, what's the
system() and popen() can do most of whatever people want to do. They can't
do everything.
/ proper Unix (or even the proper Solaris) way to do this?
/
/ I know if you have an error log file going, the error will be picked up off
/ stderr(), but I need to be able to echo tell the [non-unix inclined] user
/ immediately.
/
/
/ "To Err is human,
/ to sort of foul things up you need a computer,
/ to really ruin your day use a Microsoft product"
--
CACS: Collective Against Consensual Sanity v0.123
Now a text site map! http://www.angelfire.com/ca3/cacs/
pretty? http://www.geocities.com/SoHo/Studios/5079/
There is no sanctuary. I am an Andrea Chen plush toy.
2. vi_tutorial program
3. Making library calls from a scripting language
4. Programmers news group?
5. Making changes to env variables and making them stick
6. How to use linux xterm to run SUN X
7. Making a script to run on a directory change
8. Cyrix, Intel ??
9. dhcp calling script on change
10. Questions: bourne script call setenv & change directory
11. Continued Microsoft problems calls into question .NET
12. interrupt handler not called ( continued )
13. Bash's `continue' isn't continuing