tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Eskil.Swahn () LDC ! lu ! se
To: tru64-unix-managers
Subject: SUMMARY: Shell programming
Date: Thu, 19 Aug 1999 13:00:03 +0000	[thread overview]
Message-ID: <96079067216067.tru64-unix-managers.marc@archive.invalid> (raw)


Thanks to the people who replied.

I got several different replies to this but my main concern with the
scripts was (sorry if I didn't make this clear) to run primary script with
a lengthy operation and run the second script in the background without
having to wait for it. And 'wait' was indeed exactly what I should do.. =)

Here is how the new scripts look like now:

test.ksh:

#!/usr/bin/ksh
./test2.ksh &
PID=$!
echo "Check"        # 0 in exit status and a visual check that I get this
                    # far in the script
wait $PID           # waits for test2.ksh to finish and gets exit status
echo $?


test2.ksh:

#!/usr/bin/ksh
sleep 5
return 4


This returns '4' and there is no problem with the fact that in my real
scripts the operation instead of 'echo "Check"' takes longer time than the
script launched into the background.

/Eskil

+--------------------------------------------------------------------+
|                                                                    |
|  Eskil Swahn                                                       |
|  LDC, Lund University                                              |
|  Email: Eskil.Swahn@LDC.lu.se    Web: http://www.ldc.lu.se/        |
|  Phone: +46 46 222 4986          Fax: +46 46 138225                |
|                                                                    |
+--------------------------------------------------------------------+

---------- Forwarded message ----------
Date: Thu, 19 Aug 1999 12:13:38 +0200 (MET DST)
From: Eskil.Swahn@LDC.lu.se
To: tru64-unix-managers@ornl.gov
Subject: Shell programming


Hi!

I want to make a shell that contains the launching of another script into
the background so the two scripts run simultaneous. In the first script I
want to pick up the exit value from the subscript? I use ksh for this but
can't get it to work. I've tried something along the following method but
it doesn't do what I want:

test.ksh:

#!/usr/bin/ksh
touch ./test.output
./test2.ksh &
echo $?


test2.ksh:
#!/usr/bin/ksh
sleep 5
return 1


Running test.ksh unfortunately echoes '0' which I had hoped to be '1'. How
do I get it (if possible) to echo '1'?

/Eskil

+--------------------------------------------------------------------+
|                                                                    |
|  Eskil Swahn                                                       |
|  LDC, Lund University                                              |
|  Email: Eskil.Swahn@LDC.lu.se    Web: http://www.ldc.lu.se/        |
|  Phone: +46 46 222 4986          Fax: +46 46 138225                |
|                                                                    |
+--------------------------------------------------------------------+

                 reply	other threads:[~1999-08-19 13:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox