Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Feb 2009 12:29:19 -0800 (PST)
From:      GESBBB <gesbbb@yahoo.com>
To:        FreeBSD Users Questions <freebsd-questions@freebsd.org>
Subject:   Re: Problem with BASH and [ ! -t 0 ] test.
Message-ID:  <644168.76348.qm@web32101.mail.mud.yahoo.com>
References:  <502804.7096.qm@web32108.mail.mud.yahoo.com> <499C2F76.30507@infracaninophile.co.uk>

index | next in thread | previous in thread | raw e-mail

> From: Matthew Seaman m.seaman@infracaninophile.co.uk
> GESBBB wrote:
> | I am using this snippet of code in a bash script that is run via CRON.
> |
> |
> | 
> | # See if we are running via CRON
> |    if [ ! -t 0 ]
> |      then
> | # Use the BASH RANDOM function to generate a random number between 0 & 32767
> |        RESTING=$((RANDOM/60))
> |        sleep ${RESTING}
> |    fi
> | 
> |
> |
> | It runs fine from the console; however, when run via CRON, it outputs
> this error message.
> |
> | Tput: No terminal type specified and no TERM environmental variable.
> |
> | I have Googled about, yet I cannot find an answer. Perhaps some Bash
> guru can assist me.
> |
> 
> jot -r 1 0 546
> 
>     Cheers,
> 
>     Matthew

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?

-- 
Gerard
gesbbb@yahoo.com


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?644168.76348.qm>