From owner-freebsd-questions@FreeBSD.ORG Thu Feb 19 00:40:04 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 7E7E2106564A for ; Thu, 19 Feb 2009 00:40:03 +0000 (UTC) (envelope-from jonc@chen.org.nz) Received: from chen.org.nz (ip-58-28-152-174.static-xdsl.xnet.co.nz [58.28.152.174]) by mx1.freebsd.org (Postfix) with ESMTP id 272278FC18 for ; Thu, 19 Feb 2009 00:40:03 +0000 (UTC) (envelope-from jonc@chen.org.nz) Received: by chen.org.nz (Postfix, from userid 1000) id 628202840A; Thu, 19 Feb 2009 13:40:01 +1300 (NZDT) Date: Thu, 19 Feb 2009 13:40:01 +1300 From: Jonathan Chen To: GESBBB Message-ID: <20090219004001.GA53921@osiris.chen.org.nz> References: <502804.7096.qm@web32108.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <502804.7096.qm@web32108.mail.mud.yahoo.com> User-Agent: Mutt/1.4.2.3i Cc: FreeBSD Users Questions 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: Thu, 19 Feb 2009 00:40:04 -0000 On Wed, Feb 18, 2009 at 07:18:03AM -0800, 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. Bash is looking up the user's bash startup-scripts, and one of the script commands assumes that it's running on a terminal. -- Jonathan Chen ---------------------------------------------------------------------- "In mathematics you don't understand things. You just get used to them." - Johann von Neumann