The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 09-25-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
First of all,
Code:
#!/usr/bin/ksh 

typeset -i NO_RECS

$NO_RECS=process_file

Will not print the return code. The syntax is wrong to begin with, it should be

Code:
NO_RECS=$(process_file)

The second thing is that the return code of any command executed in the shell is not printed, but stored in a variable $?. To directly get the value that your C program has, you should do it like this:

Code:
#!/usr/bin/ksh
typeset -i NO_RECS
NO_RECS=$(process_file)

And your C program should be:

Code:
int main(argc,argv)
int argc; char *argv[];
{

int no_recs_tot ;

/* This is just a function within the c program that returns the int value */
no_recs_tot = bld_detail(v_out_path,v_in_path,inrec_cnt,v_src_data_dt);
 
fprintf(stdout,"%d",no_rec_tot);
} /* End main */