Xref: utzoo comp.unix.questions:26850 comp.unix.shell:878 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!ub!uhura.cc.rochester.edu!rochester!kodak!ispd-newsserver!weimer From: weimer@ssd.kodak.com (Gary Weimer) Newsgroups: comp.unix.questions,comp.unix.shell Subject: Re: exit value Message-ID: <1990Nov13.160213.15743@ssd.kodak.com> Date: 13 Nov 90 16:02:13 GMT References: <1990Nov12.110248@cs.utwente.nl> Sender: news@ssd.kodak.com Organization: Eastman Kodak Lines: 34 In article <1990Nov12.110248@cs.utwente.nl> stadt@cs.utwente.nl (Richard van de Stadt) writes: > > >How do I get the return value of a shell script or program that was >started (from a shell script) in the background? First the example: ------------------------- CUT HERE ---------------------- #!/bin/csh -fb #should also work with /bin/sh rm not_a_real_file_to_get_error >& /dev/null # redirection necessary for # background processes #this must be the very next statement echo "status of rm was $status" > /dev/tty # could be redirected to # any file ------------------------- CUT HERE ---------------------- rm is just the command I chose (sp?), could be any program or script. redirection necessary because background processes die if they try to access stdin or stdout. $status is the important thing here. It contains the return value (exit status) of the last command executed. you didn't specify how you wanted to "get" this value. Redirecting the echo to /dev/tty will print it to the console. Usually $status is used (at least I used it..) in a conditional statement (if, switch, etc.) Hope this answers your (vague) question. Gary Weimer