From owner-freebsd-questions Mon Nov 8 17:16:19 1999 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id E378B1523D for ; Mon, 8 Nov 1999 17:16:16 -0800 (PST) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.9.3) id UAA39447; Mon, 8 Nov 1999 20:19:14 -0500 (EST) (envelope-from cjc) From: "Crist J. Clark" Message-Id: <199911090119.UAA39447@cc942873-a.ewndsr1.nj.home.com> Subject: Re: shell's exit status variable In-Reply-To: from William Melanson at "Nov 8, 1999 02:26:28 pm" To: wjm@gate.net (William Melanson) Date: Mon, 8 Nov 1999 20:19:14 -0500 (EST) Cc: sl@zeus.dnt.md (slava revutchi), freebsd-questions@FreeBSD.ORG Reply-To: cjclark@home.com X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG William Melanson wrote, > On Mon, 8 Nov 1999, slava revutchi wrote: > > % > % Hello, > % > % How do I check the shell's exit status variable? > % > % Thanks. > % slava > % > > I know within the bash shell it would be as such: > > >[script]; echo $? > > The "$?" varaible prints the exit status of the last command run. > Either a "1" or "0". Actually I believe the return can be any int value. Many commands exit with different non-zero values depending on what type error was generated. Two quick examples, % man dump ... Dump exits with zero status on success. Startup errors are indicated with an exit code of 1; abnormal termination is indicated with an exit code of 3. ... % man grep ... Normally, exit status is 0 if matches were found, and 1 if no matches were found. (The -v option inverts the sense of the exit status.) Exit status is 2 if there were syn- tax errors in the pattern, inaccessible input files, or other system errors. ... However, '0' is the accepted value for "success," non-zero is "failure." -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message