ups 889 B

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