[plug] error msg "syntax error near unexpected token"

Jon Miller jlmiller at mmtnetworks.com.au
Sun Nov 30 21:58:04 WST 2003


Contents of backup-functions
# This is not a shell script; it provides functions for the backup.sh script
# that sources it.

# Variables
L0DATESTAMP="${BACKUPDIR}/.level0_datestamp"
NOW=`date`

# tar_backup function: does the archiving
tar_backup ()
{
  echo "Level-${LEVEL} Backup ${NOW}"
  if [ "${LEVEL}" = "0" ]; then
    # make Level-0 datestamp
    echo ${NOW} > ${L0DATESTAMP}
    # Level-0 backup
    tar --create --verbose \
        --file ${DESTFILE} \
        --blocking-factor 126 \
        --label "Level-${LEVEL} Backup ${NOW}" \
        ${BACKUPFILES}
  elif [ "${LEVEL}" = "1" ]; then
    # get last Level-0 datestamp
    LAST=`cat ${L0DATESTAMP}`
    # Level-1 backup
    tar --create --verbose \
        --file ${DESTFILE} \
        --blocking-factor 126 \
        --after-date "${LAST}" \
        --label "Level-${LEVEL} Backup from ${LAST} to ${NOW}" \
        ${BACKUPFILES}
  else
    # Backup level error
    echo "Error: Level-${LEVEL} unknown"
    exit
  fi
  echo "Level-${LEVEL} Backup END"
}

# tar_verify function: test the archive for errors
tar_verify ()
{
  echo "Level-${LEVEL} Backup Verify ${NOW}"
  # Backup verify test
  tar --list --verbose \
      --file ${DESTFILE} \
      --blocking-factor 126
  echo "Level-${LEVEL} Backup Verify END"
}

# mail_report function: sends backup report
mail_report ()
{
  # Email backup report
  mail -s "Level-${LEVEL} Backup" "${EMAILTO}" << EOF

###########################################################
Level-${LEVEL} Backup
###########################################################

Host:  ${HOSTNAME}
Files: ${BACKUPFILES}

Destination: ${DESTFILE}

###########################################################
Started:   ${NOW}
Completed: `date`
###########################################################

EOF
}

BTW - in the backup.sh file it should have for DestFile=" /dev/st0"
Jon

Jon L. Miller, MCNE, CNS, ASE
Director/Sr Systems Consultant
MMT Networks Pty Ltd
http://www.mmtnetworks.com.au

"I don't know the key to success, but the key to failure
 is trying to please everybody." -Bill Cosby



>>> devenish at guild.uwa.edu.au 8:58:41 pm 30/11/2003 >>>
In message <sfca5460.069 at mmtnetworks.com.au>
on Sun, Nov 30, 2003 at 08:34:33PM +0800, Jon  Miller wrote:
> I'm testing a backup script, when I run it I get the following:
> # ./backup.sh
> ./backup.sh: line 25: syntax error near unexpected token `tar_verify'
> ./backup.sh: line 25: `tar_verify();'
> 
> In looking at the file (/root/backup/backup.sh) that runs first it calls on 3 functions:
> tar_backup()
> tar_verify()
> mail_report()

1/ When invoking functions, don't use () and don't use ;
2/ You didn't show us what is in the backup-function file.
3/ Using `./backup-function` will *execute* that file, not *load*
   its function definitions into backup.sh.


_______________________________________________
plug mailing list
plug at plug.linux.org.au 
http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug 



_______________________________________________
plug mailing list
plug at plug.linux.org.au
http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug



More information about the plug mailing list