Modular Program of Programs

I'm writing a series of programs to work on a problem. In the end, I would like to tie them all together with as little fuss as possible. Some of the programs return values with meanings other than success or failure. But I would also like to keep the modules separately executable to be ran in any particular order. This is most useful for debugging, but may not be the only time this happens. I discovered that system() only returned 0 and -1. This is not useful when the program that was executed could return any integer greater than 0. I also found that similar functions like fork() and exec() do the same thing, which is useless. While it is possible to stick the number that needs to be returned in file and then dig it out again, that sounds like more overhead than is needed as I am only returning a number. I would much rather not open a file, insert a number, close the file, open the file, pull number out, and close the file again.

Heres what I want to do simply:
run Wrapper.out
Wrapper.out runs program a.out
a.out returns value x not related to success or failure
Wrapper.out runs program b.out with x as an argument
b.out returns 0 to Wrapper.out
Wrapper.out returns 0 to the OS

Can that be done?
Thank you kindly.
Yes. Use a temporary file.
Which one do you want?
b.out $(a.out)

a.out | b.out

a.out;
b.out $?

It should be a way to avoid disk operations.
Topic archived. No new replies allowed.