From owner-freebsd-questions@FreeBSD.ORG Wed Feb 18 20:29:20 2009 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 B6DF3106568F for ; Wed, 18 Feb 2009 20:29:20 +0000 (UTC) (envelope-from gesbbb@yahoo.com) Received: from web32101.mail.mud.yahoo.com (web32101.mail.mud.yahoo.com [68.142.207.115]) by mx1.freebsd.org (Postfix) with SMTP id 77EC98FC24 for ; Wed, 18 Feb 2009 20:29:20 +0000 (UTC) (envelope-from gesbbb@yahoo.com) Received: (qmail 77778 invoked by uid 60001); 18 Feb 2009 20:29:19 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=5tsyTFwod1jGR9k7AodLV6e8fUxqUtxpFH02RPYSTt35fcd1yV51Xn37EV5/2J8RURR3ZvGx5vYx4S7FUK68bqUb9432UO+GVJUicTxMpAyKIxmh0W53fYeKoS3gcvyN0DTgYnSM7NeLp9riAvesqmGi+2Vc7s4HOycEccpQiK8=; X-YMail-OSG: RWTeF3cVM1n8u9.ERoCJJWxWacHyudx9OR3SFSJOBtqav_7UmS2l60ci1RjHxzDVVlSiFsYMGL_TOhGoxY3xgdHoSLbVXdiFUf.846iTInS8dHWHSP26P63ANIUNR9JseA4RI8CjfXy8LmPkRgvF2JvvfvErq9aeN3LsnXa7JDnzoZjq3Uw_IOdZsf0czxEzSbybiAaGpPUfHhYS_DucYJFRZbq4UKofB3NkwoccKn3X Received: from [76.23.177.172] by web32101.mail.mud.yahoo.com via HTTP; Wed, 18 Feb 2009 12:29:19 PST X-Mailer: YahooMailRC/1156.82 YahooMailWebService/0.7.260.1 References: <502804.7096.qm@web32108.mail.mud.yahoo.com> <499C2F76.30507@infracaninophile.co.uk> Date: Wed, 18 Feb 2009 12:29:19 -0800 (PST) From: GESBBB To: FreeBSD Users Questions MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: <644168.76348.qm@web32101.mail.mud.yahoo.com> Subject: Re: Problem with BASH and [ ! -t 0 ] test. 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, 18 Feb 2009 20:29:21 -0000 > From: Matthew Seaman m.seaman@infracaninophile.co.uk=0A> GESBBB wrote:=0A= > | I am using this snippet of code in a bash script that is run via CRON.= =0A> |=0A> |=0A> | =0A> | # See if we are running via CRON=0A> |=A0 =A0 if = [ ! -t 0 ]=0A> |=A0 =A0 =A0 then=0A> | # Use the BASH RANDOM function to ge= nerate a random number between 0 & 32767=0A> |=A0 =A0 =A0 =A0 RESTING=3D$((= RANDOM/60))=0A> |=A0 =A0 =A0 =A0 sleep ${RESTING}=0A> |=A0 =A0 fi=0A> | =0A= > |=0A> |=0A> | It runs fine from the console; however, when run via CRON, = it outputs=0A> this error message.=0A> |=0A> | Tput: No terminal type speci= fied and no TERM environmental variable.=0A> |=0A> | I have Googled about, = yet I cannot find an answer. Perhaps some Bash=0A> guru can assist me.=0A> = |=0A> =0A> jot -r 1 0 546=0A> =0A> =A0=A0=A0 Cheers,=0A> =0A> =A0=A0=A0 Mat= thew=0A=0AI am a little confused. I believe the problem is with the "if [ != -t 0 ]" statement. I tried to redirect the error message; however, it stil= l 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, t= hey 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 th= e message from being sent in the CRON report?=0A=0A-- =0AGerard=0Agesbbb@ya= hoo.com