Last active
December 24, 2015 05:49
-
-
Save adri72/6752698 to your computer and use it in GitHub Desktop.
Download all the Windows 8 Drivers for the HP Spectre XT TouchSmart 15-4010nr ultrabook. This bash shell script will download all the drivers' files at once, saving hours of going around through the HP's drivers site, clicking links, saving files, etc. With minor adjustments can be used to download drivers for any other HP product.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sDate=$(date +%m%d%Y) | |
sScriptName=`basename $0` | |
sScriptName=${sScriptName%.*} | |
sDownloadFolder=${sScriptName}_${sDate} | |
#sDriversListingURL="http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=4063&lc=en&cc=us&dlc=en&sw_lang=&product=5180698#N788" | |
sDriversListingURL="http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=4063&lc=en&cc=us&dlc=en&sw_lang=&product=5278233" | |
sWgetParams="--random-wait --timeout=360 --no-check-certificate --directory-prefix=${sDownloadFolder} --limit-rate=500k --user-agent=Mozilla/5.0 " | |
if [ ! -d "$sDownloadFolder" ]; then mkdir ${sDownloadFolder}; fi | |
wget ${sWgetParams} --output-document=${sDownloadFolder}/${sScriptName}_page.html ${sDriversListingURL} | |
#read -p "Press any key to continue..." | |
grep -i '><a href="/ewfrf/wc/softwareDownloadIndex?softwareitem=' ${sDownloadFolder}/${sScriptName}_page.html | cut -d\" -f3 | sed 's/^/http:\/\/h10025.www1.hp.com/' > ${sDownloadFolder}/${sScriptName}_pageurls.txt | |
#read -p "Press any key to continue..." | |
sLoopCount=1 | |
while read line | |
do | |
echo "$line" | |
sleep 5 | |
wget ${sWgetParams} --output-document=${sDownloadFolder}/${sScriptName}_pageurlcontents_${sLoopCount}.txt "${line}" | |
sDriverURL=`grep -i 'ftp.hp.com' ${sDownloadFolder}/${sScriptName}_pageurlcontents_${sLoopCount}.txt | cut -d\" -f3 | sort --uniq` | |
sDriverPageTitle=`awk -vRS="</title>" '/<title>/{gsub(/.*<title>|\n+/,"");print;exit}' ${sDownloadFolder}/${sScriptName}_pageurlcontents_${sLoopCount}.txt | cut -d\| -f1` | |
sDriverPageTitle=${sDriverPageTitle//,/_} | |
sDriverPageTitle=${sDriverPageTitle//:/_} | |
sDriverPageTitle=${sDriverPageTitle// /_} | |
#echo "${sDriverURL}" | |
#echo "${sDriverPageTitle}" | |
#sleep 5 | |
sDriverFileName=`echo "${sDriverURL}" | cut -d\/ -f 7` | |
if [ -z "${sDriverFileName}" ]; then sDriverFileName="sp_undetermined_${sLoopCount}.exe"; fi | |
echo "${sDriverPageTitle}${sDriverFileName}" | |
sleep 5 | |
wget ${sWgetParams} --output-document="${sDownloadFolder}/${sDriverPageTitle}${sDriverFileName}" "${sDriverURL}" | |
#echo "wget ${sWgetParams} --output-document=\"${sDownloadFolder}/${sDriverPageTitle}${sDriverFileName}\" \"${sDriverURL}\"" >> ${sDownloadFolder}/wget_download_cmds.txt | |
sSecsToWait=$[ ( $RANDOM % 2 ) + 1 ] | |
echo "Waiting ${sSecsToWait} seconds..." | |
sleep ${sSecsToWait} | |
#rm ${sDownloadFolder}/${sScriptName}_pageurlcontents_${sLoopCount}.txt | |
let sLoopCount++ | |
done < ${sDownloadFolder}/${sScriptName}_pageurls.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment