[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-developers] Shell Script Errors



Kevin,

The shell script code looks pretty weird, so I'm wondering if it didn't get
mangled in the email.  Just in case though, here's a couple of pointers.

DOW='date +%w' means DOW equals exactly what you wrote.
DOW=`date +%w` means DOW equals the output of the date command.

The right hand side of an assignment should always be quoted to gaurd against
unexpected spaces.

DOW="`date +%w`"

case "date +%H:%M" in   should be  case "`date +%H:%M`"

Quote the case targets if there's any chance the shell might interpret the
characters.

"10:00")

I noticed also some unbalanced quotes:

"14:00) bru -L "${TIME}'s HourlyBackup" -cvvvVZXGBf 

Also, the last statement of the case statement is garbled.

*) exit *  should probably be  *) exit;;

The behavior you are seeing is usually the result of unbalanced single or
double quotes or spaces in unexpected places.  Hope this helps.

Tom Cox

On Fri, 02 Mar 2001, you wrote:
> Alright, I'm writing a simple shell script to execute a few commands based
> on what time of day it is, after fixing the outdated and stripped down
> version of the date command cobalt has on its Qube3's I managed to get the
> command line to start printing out times via 'date +%H%M' (to print out
> Hour:Minute) but now I'm having problems with my case statments and I'm not
> sure why its happening. Below I'm stating the exact instances where I'm
> having problems:
> 
> 	[root /root]# sh qubebackup-0.4.sh
> I run the shell script, it starts printing errors
> 
> 	: command not found
> 	: command not found
> 	: command not found
> 	: command not found
> 	: command not found
> 	"t: unknown command "status
> 
> To this point there are no commands being issued, I'm setting variables
> like:
> BUFSIZE="32k"
> DOW=`date +%w`
> TIME='date +%H:%M'
> HOUR='date +%H'
> DATE=`date +%D`
> DAY=`date +%A`
> DEVICE="/dev/nst0"
> DATA="/home"
> REWIND="mt -f /dev/nst0 rewind"
> EOD="mt -f /dev/nst0 eod"
> FSF="mt -f /dev/nst0 fsf"
> 
> 	usage: mt [-v] [--version] [-h] [ -f device ] command [ count ]
> 	commands: weof, wset, eof, fsf, fsfm, bsf, bsfm, fsr, bsr, fss, bss,
> rewind,
>           	offline, rewoffl, retension, eod, seod, seek, tell, status,
>           	erase, setblk, lock, unlock, load, compression, setdensity,
>           	drvbuffer, stwrthreshold, stoptions, stsetoptions,
> stclearoptions,
>           	defblksize, defdensity, defdrvbuffer, defcompression, sttimeout,
>           	stlongtimeout, densities, setpartition, mkpartition, partseek,
>           	asf.
> 
> I'm not quite sure WHY its printing this out considering its in responce to:
> mt -f /dev/nst0 status
> which should give me an echo of the status of the non rewinding device.
> 
> 	: command not found
> 
> Here this is again... I'm going crazy, I swear.
> 
> 	'ubebackup-0.4.sh: syntax error near unexpected token `in
> 	'ubebackup-0.4.sh: qubebackup-0.4.sh: line 63: `case "$TIME" in
> 
> This one I really don't get, its in reponce to my case statement:
> case "date +%H:%M" in
> 	10:00) bru -L "${TIME}'s Hourly Backup" -cvvvVZXGBf \
> 		        $DEVICE $DATA > /tmp/backup.txt
> 		   mail $MAILLIST < /tmp/backup.txt
> 	;;
> 	12:00) bru -L "${TIME}'s Hourly Backup" -cvvvVZXGBf \
> 		        $DEVICE $DATA > /tmp/backup.txt
> 		   mail $MAILLIST < /tmp/backup.txt
> 	;;
> 	"14:00) bru -L "${TIME}'s Hourly Backup" -cvvvVZXGBf \
> 		        $DEVICE $DATA > /tmp/backup.txt
> 		   mail $MAILLIST < /tmp/backup.txt
> 	;;
> 	"16:00") bru -L "${TIME}'s Hourly Backup" -cvvvVZXGBf \
> 		        $DEVICE $DATA > /tmp/backup.txt
> 		   mail $MAILLIST < /tmp/backup.txt
> 	;;
> 	18:00) bru -L "${TIME}'s Hourly Backup" -cvvvVZXGBf \
> 		        $DEVICE $DATA > /tmp/backup.txt
> 		   mail $MAILLIST < /tmp/backup.txt
> 	;;
> 	*) exit *
> esac
> 
> Am I going insane? Can someone help me out? I mean this should be working,
> simple line by line from any good linux developers book would tell me that,
> so I must be missing something.
> 
> _______________________________________________
> cobalt-developers mailing list
> cobalt-developers@xxxxxxxxxxxxxxx
> http://list.cobalt.com/mailman/listinfo/cobalt-developers
-- 
--------------------
Tom A. Cox
Senior Programmer
Tri-Pacific Software
972-620-2520 ext. 23
www.tripac.com