From owner-freebsd-questions@FreeBSD.ORG Wed Apr 20 13:01:29 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD73D106564A for ; Wed, 20 Apr 2011 13:01:29 +0000 (UTC) (envelope-from mail25@bzerk.org) Received: from ei.bzerk.org (tunnel490.ipv6.xs4all.nl [IPv6:2001:888:10:1ea::2]) by mx1.freebsd.org (Postfix) with ESMTP id 51B2B8FC08 for ; Wed, 20 Apr 2011 13:01:29 +0000 (UTC) Received: from ei.bzerk.org (BOFH@localhost [127.0.0.1]) by ei.bzerk.org (8.14.4/8.14.4) with ESMTP id p3KD16W6030378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 20 Apr 2011 15:01:07 +0200 (CEST) (envelope-from mail25@bzerk.org) Received: (from bulk@localhost) by ei.bzerk.org (8.14.4/8.14.4/Submit) id p3KD16Q4030377; Wed, 20 Apr 2011 15:01:06 +0200 (CEST) (envelope-from mail25@bzerk.org) Date: Wed, 20 Apr 2011 15:01:06 +0200 From: Ruben de Groot To: Bastien Semene Message-ID: <20110420130106.GA30295@ei.bzerk.org> Mail-Followup-To: Ruben de Groot , Bastien Semene , freebsd-questions@freebsd.org References: <4DAD9594.8030108@cyanide-studio.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DAD9594.8030108@cyanide-studio.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on malenfant.lan X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (ei.bzerk.org [127.0.0.1]); Wed, 20 Apr 2011 15:01:08 +0200 (CEST) Cc: freebsd-questions@freebsd.org Subject: Re: redirecting command output depending on exit status X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2011 13:01:29 -0000 On Tue, Apr 19, 2011 at 04:00:52PM +0200, Bastien Semene typed: > Hi list, > > I have a cron task set up using lockf. > > I'd like to redirect one exit status to /dev/null : > > "it (lockf command) returns one of the exit codes defined in > sysexits(3), as follows: > > EX_TEMPFAIL The specified lock file was already locked by another > process. > > EX_CANTCREAT The lockf utility was unable to create the lock > file, e.g., > because of insufficient access privileges. > > EX_USAGE There was an error on the lockf command line. > > EX_OSERR A system call (e.g., fork(2)) failed unexpectedly. > > EX_SOFTWARE The command did not exit normally, but may have been > sig- > naled or stopped." > > I don't care about the EX_TEMPFAIL output as I consider it as a > successful exit status, not an error. > > I there a trick to do that in a short way ? something like logfile=/var/log/lockf.log lockf lockfile command [ $? -eq 75 ] && logfile=/dev/null ## EX_TEMPFAIL is defined to be 75 Ruben