Date: Sun, 28 Jul 2002 12:26:35 -0400 (EDT) From: Jason Hunt <leth@primus.ca> To: freebsd-questions@FreeBSD.ORG Cc: Michelle Weeks <tristan11@mindspring.com> Subject: Re: Backup Scripts Message-ID: <20020728120510.J1068-100000@lethargic.dyndns.org> In-Reply-To: <5703127A-9FEF-11D6-A5A4-00039368B8EC@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 25 Jul 2002, Michelle Weeks wrote: > #! /bin/sh > # Variables > EMAILTO=backup > DESTFILE=/dev/nrsa0 > BACKUPFILES="/var /usr/home" > BACKUPDIR=${HOME}/backup > LEVEL=1 In your original message on July 23rd, you had "LEVEL=${0}" instead of "LEVEL=0" or "LEVEL=1". With "LEVEL=${0}", you were getting "Error: Level-backup.sh unknown" when you tried to run the script. ${0} is a variable for the name of the script. ${1} through ${9} are for command-line arguments. It seems that the person who wrote this script intended it to be ran as "backup.sh 0" or "backup.sh 1", and that argument is passed to ${LEVEL}. The script then checks for ${LEVEL} to be of the value "0" or "1", otherwise it exits with the "Level-${LEVEL} unknown" error. The code for that is in the tar_backup() function: if [ "${LEVEL}" = "0" ]; then <... etc ...> elif [ "${LEVEL}" = "1" ]; then <... etc ...> else # Backup level error echo "Error: Level-${LEVEL} unknown" exit What you might want to do is put "LEVEL=${1}" and then run the script using "backup.sh 0" and "backup.sh 1" to get the different levels without having to modify the file. Does any of this make sense? I'm better at programming, not explaining or teaching it. :) > Level-1 Backup END > Level-1 Backup Verify Wed Jul 24 15:38:47 PDT 2002 > tar: echo not found in archive > tar: Level-1 Backup Verify END not found in archive > [ ... snip ... ] > > # tar_verify function: test the archive for errors > tar_verify () > { > echo "Level-${LEVEL} Backup Verify ${NOW}" > # Backup verify test > tar --list --verbose \ > --file ${DESTFILE} \ > echo "Level-${LEVEL} Backup Verify END" > } > The \ at the end of a line means that the said line continues onto the next (line). The script is trying to run the command "tar --list --verbose --file ${DESTFILE} echo "Level-${LEVEL} Backup Verify END"". Remove the \ off the end of "--file ${DESTFILE} \". This will cause the script to run "tar --list --verbose --file ${DESTFILE}" and then " echo "Level-${LEVEL} Backup Verify END"", which seems to be the intention. Hope this helps. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020728120510.J1068-100000>