Re: redirecting command output depending on exit status
I have a cron task set up using lockf. I'd like to redirect one exit status to /dev/null : I think that the exit status of a command will be after any output of the command to stderr or stdout. So first it will say This is wrong and then it will exit giving you the exit code. The only thing I can think of is to write a wrapper script which in effect parses out the error message for example: command | grep -v offending message logfile Regards Riaan ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: redirecting command output depending on exit status
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-unsubscr...@freebsd.org
Re: redirecting command output depending on exit status
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-unsubscr...@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 ! ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
redirecting command output depending on exit status
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 ? -- Bastien Semene Administrateur Réseau Système Cyanide Studio - FRANCE ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org