From owner-freebsd-questions@FreeBSD.ORG Tue Jun 21 10:05:25 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A1A9916A41C for ; Tue, 21 Jun 2005 10:05:25 +0000 (GMT) (envelope-from cknipe@hybyte.com) Received: from mail.uk.hybyte.net (mail.uk.hybyte.net [213.86.56.137]) by mx1.FreeBSD.org (Postfix) with ESMTP id 455DD43D55 for ; Tue, 21 Jun 2005 10:05:25 +0000 (GMT) (envelope-from cknipe@hybyte.com) Received: from localhost (localhost [127.0.0.1]) by mail.uk.hybyte.net (Postfix) with ESMTP id BF5A9EB2E1 for ; Tue, 21 Jun 2005 11:02:29 +0100 (BST) Received: from by localhost (amavisd-new, port ) id cYWdKtPV for ; Tue, 21 Jun 2005 11:02:28 +0100 (BST) Received: from MEGADROID (wbs-146-184-170.telkomadsl.co.za [165.146.184.170]) by mail.uk.hybyte.net (Postfix) with ESMTP id 861C5EB2A6; Tue, 21 Jun 2005 11:02:26 +0100 (BST) Message-ID: <017601c57648$ba663330$0b02a8c0@MEGADROID> From: "Chris Knipe" To: "Alex Zbyslaw" References: <000601c57642$edfce460$1e01a8c0@pc2xp> <42B7E5B3.3080706@dial.pipex.com> Date: Tue, 21 Jun 2005 12:05:11 +0200 Organization: HyByte MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Virus-Scanned: by amavisd-new at hybyte.com Cc: freebsd-questions@freebsd.org Subject: Re: OT Shell Script 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: Tue, 21 Jun 2005 10:05:25 -0000 Call me stupid, I wasn't aware that [ is a command... ;) Thanks, Chris. ----- Original Message ----- From: "Alex Zbyslaw" To: "Chris Knipe" Cc: Sent: Tuesday, June 21, 2005 12:02 PM Subject: Re: OT Shell Script > Chris Knipe wrote: > >>May be a bit off topic, but I don't know any sh scripting lists that I'm >>subscribed to... :) >> >>If I run the script from shell / console, it runs without a problem.... >>Running it via cron, I get: [: 6: unexpected operator >> >>The script: >>#!/bin/sh >>HOSTNAME=`/usr/bin/uname -n` >>SIZE=`/usr/bin/du /var/log/MYAPP/|/usr/bin/cut -c 1-7` >>ROTATE="1024000" >>if [ -e /tmp/.rotate ]; then >> > Maybe your path doesn't have [ in it. Try > > if /bin/[ -e /tmp/.rotate ]; then > > or > > if /bin/test -e /tmp/.rotate; then > > Same for all your other [ tests. > > Or just make sure that /bin is in your path at the top of the script. > It's often a good idea to set path explicitly for scripts, in case someone > who runs it has something weird in their path, like their own [ or test or > whatever. I notice the rest of the commands all have absolute pathnames > avoiding the path issue, but I like setting the path anyway as it's really > easy to forget to use absolute pathnames since we are so used to the shell > finding things for us at the command line. > > --Alex > > > --Alex > >