return code from script

hey all,

I have a simple script 

\#!/bin/bash 

./cron.sh test_a.txt &
./cron.sh test_b.txt &

 wait

I want to invoke another program based on the return status of the above calls. How am I were to get that? Thanks!

Hi,
I am also facing the same iissue if any one can reply it would be very helpful for me.

Well...the short answer is "you can't do that". In the above example, the return code is lost.

One answer is to write the return code to a file:

(myscript.sh; echo $? > /tmp/rc1) &
wait
RC1=$(cat /tmp/rc1)

You would need to make sure the temporary file is unique, but this should work. There aren't any elegant solutions, really.