ups 806 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/rc
  2. # lucent web proxy caches the page; defeat it
  3. rfork n
  4. if(! ~ $#* 1) {
  5. echo usage: ups 1ZA41W190338680961 >[1=2]
  6. exit usage
  7. }
  8. rfork e
  9. hget 'http://wwwapps.ups.com/etracking/tracking.cgi?track=Track&InquiryNumber1='^$1^ \
  10. '&TypeOfInquiryNumber=T' >/tmp/ups.1
  11. cat /tmp/ups.1 |
  12. x=`{sed -n 's/^<INPUT TYPE="HIDDEN" NAME="([^"]+)" VALUE="([^"]+)">.*/\1=\2/p' |
  13. tr ' ' ++}
  14. x=$"x
  15. x=`{echo $x | sed 's/ /\&/g'}
  16. x=$"x
  17. x=$x^'&tdts1.x=19&tdts1.y=7'
  18. hget -p $x http://wwwapps.ups.com/etracking/tracking.cgi >/tmp/ups.2
  19. sed 's/<[Tt][Dd]>/& «TD»/g; s/<[Tt][Rr]>/&<td> «TR» /g' /tmp/ups.2 |
  20. htmlfmt >/tmp/ups.3
  21. sam -d /tmp/ups.3 >[2] /dev/null <<'!'
  22. /^Tracking results.*/p
  23. .,$d
  24. /View Details/d
  25. 1,.d
  26. ,s/\n/ /g
  27. ,s/«TR»/\n/g
  28. ,s/«TD»/ /g
  29. ,s/ * */ /g
  30. ,s/^[ ]*//g
  31. ,s/[ ]*$//g
  32. ,s/\n\n+/\n\n/g
  33. ,p
  34. !