Date: Tue, 21 Jun 2005 11:02:27 +0100 From: Alex Zbyslaw <xfb52@dial.pipex.com> To: Chris Knipe <cknipe@hybyte.com> Cc: freebsd-questions@freebsd.org Subject: Re: OT Shell Script Message-ID: <42B7E5B3.3080706@dial.pipex.com> In-Reply-To: <000601c57642$edfce460$1e01a8c0@pc2xp> References: <000601c57642$edfce460$1e01a8c0@pc2xp>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42B7E5B3.3080706>