Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Feb 2009 12:47:01 -0800
From:      Chuck Swiger <cswiger@mac.com>
To:        GESBBB <gesbbb@yahoo.com>
Cc:        FreeBSD Users Questions <freebsd-questions@freebsd.org>
Subject:   Re: Problem with BASH and [ ! -t 0 ] test.
Message-ID:  <5A806B91-857E-4084-9CB3-0F87E2C46786@mac.com>
In-Reply-To: <644168.76348.qm@web32101.mail.mud.yahoo.com>
References:  <502804.7096.qm@web32108.mail.mud.yahoo.com> <499C2F76.30507@infracaninophile.co.uk> <644168.76348.qm@web32101.mail.mud.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Feb 18, 2009, at 12:29 PM, GESBBB wrote:
> I am a little confused. I believe the problem is with the "if [ ! -t  
> 0 ]" statement. I tried to redirect the error message; however, it  
> still appears in the email sent by CRON. I tried using this  
> statement instead: if ( ! tty -s &> /dev/null ) and "if ( ! tty -s )  
> &> /dev/null"; however, they also produce an error message although  
> the function does work correctly. Is this just something I should  
> just ignore, or is there a way to stop the message from being sent  
> in the CRON report?

For Bourne shell, classic /bin/sh, and related shells (zsh, ksh), you  
can use something like:

case $- in
     *i*)
     # do stuff for an interactive shell
     echo "interactive"
     ;;
     *)
     # not interactive
     echo "not interactive"
     ;;
esac

Regards,
-- 
-Chuck




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5A806B91-857E-4084-9CB3-0F87E2C46786>