From owner-freebsd-questions Sun Oct 1 11:34: 4 2000 Delivered-To: freebsd-questions@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 6BB4B37B66C for ; Sun, 1 Oct 2000 11:33:58 -0700 (PDT) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e91IXvm17467; Sun, 1 Oct 2000 11:33:57 -0700 (PDT) Date: Sun, 1 Oct 2000 11:33:57 -0700 From: Alfred Perlstein To: krishna vallapareddy Cc: freebsd-questions@FreeBSD.ORG Subject: Re: statuses of background jobs in shell scripts Message-ID: <20001001113357.F27736@fw.wintelcom.net> References: <00d801c02bd1$f18b4790$7ac9010a@kvalpareddy_lp.appworx.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i In-Reply-To: <00d801c02bd1$f18b4790$7ac9010a@kvalpareddy_lp.appworx.com>; from kvallapareddy@appworx.com on Sun, Oct 01, 2000 at 02:03:46PM -0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * krishna vallapareddy [001001 11:08] wrote: > Hi, > I would like to know how I can redirect the 'Done x' > messages that you would get if a job were submitted at > the command line to a file. Also, this does not happen > when the job is submitted in a shell script. > My problem is, I need to submit a lot of jobs in the > background in a loop based on a counter that I increment using expr command. > After that I need to > track the statuses of each of these jobs. If the job has > not finished, I could use the wait command but how do I > get the statuses of the jobs that have already finished? > > Any help in this regard is highly appreciated. First off you don't mention which shell you're using, so I'm assuming 'sh' because it's the only shell one should program for. basically: #!/bin/sh (sleep 3 ; echo done; exit 5) & pid=$! echo before wait $pid status=$? echo $pid exited with status $status good luck, -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message