return parameters from shell script

Hi All
I came now to a point in my project where Iam using

the system() command to run shell script files (.sh) , here is my question

Can I return parameters or variables from the results of script file run to the main C code where it is called from.

Also does the QNX script support IF ELSE or looping when you write the script code.

Thank u very much all.

Ehabk71,

You can return at least an exit status from the script to the main C code (usually 0 or -1 for success/fail). Not sure about more than that.

Absolutely. Those and MANY more.

In the helpview type in ‘ksh’ for the Korn Shell (which is the one I assume you are using). It brings up very detailed info on the script commands you can use, what can be returned and some examples of how to do it. I didn’t read it all (it’s a large section) but the answers you want are definitely there.

Tim

There are a lot of kludgy ways to return information from a script to the calling ‘C’ program.
The simplest I can think of, is to write a file in the shell script and read it from your ‘C’ program after the shell script returns. You could skip the file by creating a pipe in the ‘C’ program, and making the output from the script the pipe. There is nothing inherent like global data, or passing pointer references.