I am one of those people who hates doing someone else's work. However, hence I am learning bash and need as much practice as I can get I can atleast post some of the initial code which I think can be helpful.
I would also appreciate others to chime in and let me know how I can better my script snippets.
Code:
#!/bin/bash
HOME=/home/user/scripts/bash/html
LOGFILE=$HOME/wget.log
DATE=`date +%Y-%m-%d`
wget http://www.somesite.net/index.html
zip-file () {
for i in $HOME/index.html; do
zip -j backup_`date +%Y-%m-%d`.zip $i
done
}
if [ -f $HOME/index.html ]; then
zip-file;
echo -n $DATE: file here... > $LOGFILE
else
echo -n $DATE: no file here... > $LOGFILE
exit 1
fi
Ok so now I need help. I've added to the script snippet above and wanted to use the elif clause, however, I am tired and need a hand. Here is what I have thus far.
Please someone chime in
Code:
#!/bin/bash
HOME=/home/user/scripts/bash/html
TMP=$HOME/tmp
LOGFILE=$HOME/wget.log
DATE=`date +%Y-%m-%d`
WGET="wget -P $TMP http://www.somesite.net/index.html"
zip-file () {
for i in $TMP/index.html; do
zip -mj $TMP/backup_`date +%Y-%m-%d`.zip $i
done
}
if [ ! -d $TMP ]; then
mkdir $TMP
fi
if [ ! -f $TMP/index.html ]; then
$WGET
fi
if [ -f $TMP/index.html ]; then
zip-file;
echo -n $DATE: file here... >> $LOGFILE
else
echo -n $DATE: no file here... >> $LOGFILE
exit 1
fi