IsraelTorres

get-dell-elements.sh

Nov 9th, 2011
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #/bin/bash
  2. # ./get-dell-elements.sh
  3. # Israel Torres 20110307
  4. # Dell multiple hooks at one time with one file
  5.  
  6. dellurl='http://support.dell.com/support/topics/global.aspx/support/my_systems_info/en/details?c=us&cs=04&l=en&s=hied&ServiceTag='
  7. tempfile=$(date +%s)
  8. filter1="System Type:"
  9. filter2="Ship Date:"
  10.  
  11. for SN in $(cat dell.txt)
  12.     do
  13.     #echo -ne "$SN\t"
  14.     curl -s $dellurl$SN | tr "\"" "\n" > $tempfile
  15.     DellSysType=$(cat $tempfile | grep "$filter1" -A 4 | grep '</td></tr><tr><td class=' | sed 's/<\/td><\/tr><tr><td class=//g' | sed 's/>//g')
  16.     DellShpDate=$(cat $tempfile | grep "$filter2" -A 4 | grep '</td></tr><tr><td class=' | sed 's/<\/td><\/tr><tr><td class=//g' | sed 's/>//g')
  17.    
  18.     echo -e "$SN\t$DellSysType\t$DellShpDate"
  19. done
  20.  
  21. rm -f tempfile
  22.  
RAW Paste Data