From owner-freebsd-questions@FreeBSD.ORG Wed Apr 20 15:19:54 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 505EC1065672 for ; Wed, 20 Apr 2011 15:19:54 +0000 (UTC) (envelope-from bsemene@cyanide-studio.com) Received: from mail.cyanide-studio.com (mail.cyanide-studio.com [62.73.7.64]) by mx1.freebsd.org (Postfix) with ESMTP id 0BE4A8FC08 for ; Wed, 20 Apr 2011 15:19:53 +0000 (UTC) Received: from localhost (unknown [10.1.8.14]) by mail.cyanide-studio.com (Postfix) with ESMTP id 7366617BF447 for ; Wed, 20 Apr 2011 17:19:52 +0200 (CEST) Received: from mail.cyanide-studio.com ([10.1.8.3]) by localhost (mailguard.cyanide-studio.com [10.1.8.14]) (amavisd-maia, port 10024) with ESMTP id 23307-03 for ; Wed, 20 Apr 2011 17:19:52 +0200 (CEST) Received: from [10.1.8.96] (unknown [10.1.8.96]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: bsemene@cyanide-studio.com) by mail.cyanide-studio.com (Postfix) with ESMTP id 4ACA317BF440 for ; Wed, 20 Apr 2011 17:19:52 +0200 (CEST) Message-ID: <4DAEF997.6070400@cyanide-studio.com> Date: Wed, 20 Apr 2011 17:19:51 +0200 From: Bastien Semene User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <4DAD9594.8030108@cyanide-studio.com> <20110420130106.GA30295@ei.bzerk.org> In-Reply-To: <20110420130106.GA30295@ei.bzerk.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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 15:19:54 -0000 Bastien Semene Administrateur Réseau& Système Cyanide Studio - FRANCE Le 20/04/2011 15:01, Ruben de Groot a écrit : > 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 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" I used this $? test in a script. My question was to know if it is possible to do this in 1 command line, but I found nothing anywhere to do this. Thank you for the answer !