I am trying to run a C executable from within a Korn Shell Unix script. The C executable is to create a csv file and returns 0, 1, or -1 depending on success, warning, or failure. I am able to execute the code successfully from Kshell because the csv file is created. But I am unable to capture the return code (0,1,or -1) in a Kshell variable for testing purposes. Below is a code snippet I am using now that successfully runs and executes the C code but does not capture the return code. Parameters passed to the C code (named " cexecutable" for purposes of discussion) are a variable $harness and output directory "/home/user/me/outdir/":
output=`/home/user/me/cexecutable $harness /home/user/me/outdir/ `
echo "OUTPUT is = " $output >> $outfile
if [ $output -eq 0 ]; then
echo $output " - CSV success!" >> $outfile............
and so on...
$output does not seem to capture the return code...not sure if I have a syntax error or it is a C issue.
Thanks for the help in advance!