alex0 |
07-26-2009 03:32 AM |
syntax error near unexpected token `else'
hey im alex ive been using linux(ubuntu now) for about 4 or 5 years now and ive recently been getting into bash scripts and have ran across a problem with this rsync script i made from here and there...
Code:
#!/bin/bash
# Lock file in the /tmp directory
LOCKFILE="/tmp/backup.lck"
# Place a log file in ?? and choose the date format
LOGFILE='/home/alex/bin/log/lock/back/'`date +%d-%m-%Y`'.txt'
# Append start time to the log file
date +[G\ O\ %H:%M] >> $LOGFILE
# Check wether we have a lock file, if so, don't execute
if [ -f $LOCKFILE ]; then
date +[N\ O\ %H:%M] && echo /tmp/backup.lck exists, aborting >> $LOGFILE
sleep 5; notify-send "Rsync" "Rsync is either already running or the lock is stuck!" -i /home/alex/bin/locked.png
exit 1
fi
# Create the lock file
/bin/touch $LOCKFILE
date +[M\ K\ %H:%M]'Lock Created' >> $LOGFILE
# Do your thing here
ogg123 /home/alex/bin/dialog-warning.ogg
notify-send "Rsync" "Backup Started" -i /home/alex/bin/rsync.png
rsync -av /mnt/200GB/Homework /media/120GB/backup/200GB
rsync -av /mnt/200GB/Misc /media/120GB/backup/200GB
rsync -av /mnt/200GB/Music /media/120GB/backup/200GB
rsync -av /mnt/200GB/Pictures /media/120GB/backup/200GB
rsync -av --exclude='home/alex/.purple/custom_smiley' --exclude='/home/alex/.Xauthority' --exclude='home/alex/.mozilla/firefox-3.5/dh2i004w.default/Cache/' /home /media/120GB/backup
ogg123 /home/alex/bin/dialog-warning.ogg
sleep 3; notify-send "Rsync" "Backup Finished" -i /home/alex/bin/rsync.png
# Done, removing lock file
rm -f $LOCKFILE
if [ -f $LOCKFILE ]; then
else sleep 5; notify-send "Rsync" "Lock File Deleted" -i /home/alex/bin/unlocked.png && date +[U\ N\ %H:%M] >> $LOGFILE
exit
rm -f $LOCKFILE
if [ -f $LOCKFILE ]; then
else sleep 5; notify-send "Rsync" "Lock File Deleted" -i /home/alex/bin/unlocked.png && date +[U\ N\ %H:%M] >> $LOGFILE
exit
rm -f $LOCKFILE
if [ -f $LOCKFILE ]; then
else
sleep 5; notify-send "Rsync" "Lock File Deleted" -i /home/alex/bin/unlocked.png && date +[U\ N\ %H:%M] >> $LOGFILE
exit
rm -f $LOCKFILE
if [ -f $LOCKFILE ]; then
else
sleep 5; notify-send "Rsync" "Lock File Deleted" -i /home/alex/bin/unlocked.png && date +[U\ N\ %H:%M] >> $LOGFILE
exit
rm -f $LOCKFILE
if [ -f $LOCKFILE ]; then
sleep 5; notify-send "Rsync" "Lock File Wont Delete" -i /home/alex/bin/dialog-warning.png && date +[X\ X\ %H:%M] Rsync - Lock File Wont Delete >> $LOGFILE
exit
which returns...
Code:
$ /home/alex/bin/backup.sh
Audio Device: Advanced Linux Sound Architecture (ALSA) output
Playing: /home/alex/bin/dialog-warning.ogg
Ogg Vorbis stream: 1 channel, 44100 Hz
Done.
sending incremental file list
sent 10188 bytes received 58 bytes 20492.00 bytes/sec
total size is 793425369 speedup is 77437.57
sending incremental file list
sent 868029 bytes received 2337 bytes 580244.00 bytes/sec
total size is 28075264059 speedup is 32256.85
sending incremental file list
sent 135941 bytes received 165 bytes 90737.33 bytes/sec
total size is 15872919956 speedup is 116621.75
sending incremental file list
sent 21050 bytes received 51 bytes 42202.00 bytes/sec
total size is 126688735 speedup is 6003.92
sending incremental file list
home/alex/
home/alex/.xsession-errors
home/alex/.cache/notify-osd.log
home/alex/.gconfd/
home/alex/.gconfd/saved_state
home/alex/.mozilla/firefox-3.5/dh2i004w.default/
home/alex/.mozilla/firefox-3.5/dh2i004w.default/sessionstore.js
home/alex/bin/
home/alex/bin/backup.sh
home/alex/bin/backup.sh~
home/alex/bin/log/lock/back/26-07-2009.txt
sent 976972 bytes received 2137 bytes 652739.33 bytes/sec
total size is 2769633682 speedup is 2828.73
Audio Device: Advanced Linux Sound Architecture (ALSA) output
Playing: /home/alex/bin/dialog-warning.ogg
Ogg Vorbis stream: 1 channel, 44100 Hz
Done.
/home/alex/bin/backup.sh: line 37: syntax error near unexpected token `else'
/home/alex/bin/backup.sh: line 37: `else sleep 5; notify-send "Rsync" "Lock File Deleted" -i /home/alex/bin/unlocked.png && date +[U\ N\ %H:%M] >> $LOGFILE'
help anyone?? i know that the problem is with getting my else to
Quote:
sleep 5; notify-send "Rsync" "Lock File Deleted" -i /home/alex/bin/unlocked.png && date +[U\ N\ %H:%M] >> $LOGFILE
exit
|
|