Aqui está um script simples que pode ajudar você a começar:
#!/bin/sh
# Make sure a URL is passed first
if [ -z "$1" ]
then
echo "
Pass the full URL to be downloaded. For example:
${0##*/} \"http://websitehttp/website.file.extension\"
If that URL fails, then \"http://website.file.extension\"
will be tried automatically.
"
exit 1
fi
# Attempt download
wget -v "${1}"
# Check for an error and if so, try an alternative download
if [ "$?" != "0" ]
then
url2='echo ${1} | cut -d '/' -f 4-'
# DEBUG echo "[$url2]"
wget -v "http://${url2}"
fi
echo "Done"
exit 0