Hi all,
I'm still learning about bash scripting. Not too long ago, with a lot of help from folks on this forum, I developed the following script to keep Slackware -stable up-to-date:
Code:
#!/bin/bash
#update_slackware.sh
#Note: run this script as root from the local ./patches directory.
#Synchronize the local mirror with the remote mirror.
# The -e and -n switches delete old packages and only
# download the new ones:
lftp -c "open ftp://my-favorite-mirror/slackware-version/patches/ ; mirror -e -n packages"
#Download the most recent CHECKSUMS.md5 file:
rm -f CHECKSUMS.md5
lftp -c get ftp://my-favorite-mirror/slackware-version/patches/CHECKSUMS.md5
#Check for MD5 checksum errors and exit if some are found.
if grep "\./packages/" CHECKSUMS.md5 | md5sum -c | grep -v OK$
then echo "Script aborting. Try manually downloading the file(s) listed above"
exit 1
fi
#Upgrade Slackware with downloaded packages:
echo "No errors found; updating with new packages."
upgradepkg ./packages/*.txz
#Find configuration files that need attention:
echo "Checking for new configuration files:"
find /etc -name "*.new"
I'm happy with this script. I've tested it and it works well. However, I'd like to log the output into a file,
but I also want to see it on the screen.
I know I can put:
Code:
>> recent_update_log.txt
after each of the commands above, but is that the best way to log the output? Can I still see the results on the screen as they happen?
I thought I would add something like:
Code:
FILEDATE=$(date +%Y%m%d)
And then something like this after each command:
Code:
lftp whole bunch of stuff >> $FILEDATE_update_log.txt
Am I on the right track?
Regards,
-Drew