[Techtalk] Shell script problem

Almut Behrens almut-behrens at gmx.net
Thu Jul 14 08:22:12 EST 2005


On Wed, Jul 13, 2005 at 12:58:19PM -0700, Lucky Lady wrote:
> I wrote the follwing script to zip the contents of my
> acct directory and put the zip in my data directory.
> However, when the script runs the following message
> appears: "zip warning: /home/acct.zip not found or
> empty". What am I doing wrong? My script:
> 
> #!/bin/sh
> #
> #
> DATADIR="/home/acct"
> BACKUPFILE=$1
> BACKUPPATH="/home/daly/bkup/data";
> #
> echo Backup Date: $(date) > $BACKUPPATH/$BACKUPFILE.log
> echo Backup Target: $DATADIR >> $BACKUPPATH/$BACKUPFILE.log
> #
> if (ls $DATADIR) then
>     echo "Backing up " $DATADIR;
>     cd $BACKUPPATH;
>     zip -ruv $BACKUPFILE $DATADIR >> $BACKUPPATH/$BACKUPFILE.log
> fi;

I think you get that message just because you've given the -u option.
zip issues this warning if there's no .zip file to update, yet (when
you run the command for the first time).

What's a little strange is the name "/home/acct.zip"... Are you
actually passing some file name (the parameter $1) to the script?
In case not the zip command would collapse to

  zip -ruv $DATADIR >> ...

which might explain why it's trying to access /home/acct.zip :)

Cheers,
Almut



More information about the Techtalk mailing list