ups 560 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/rc
  2. # ups - look up a UPS tracking number
  3. rfork en
  4. if(! ~ $#* 1) {
  5. echo usage: ups 1ZA41W190338680961 >[1=2]
  6. exit usage
  7. }
  8. hget 'http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum='^$1^ \
  9. '&TypeOfInquiryNumber=T' >/tmp/ups.1
  10. sed 's/<[Tt][Dd]>/& «TD»/g; s/<[Tt][Rr]>/&<td> «TR» /g' /tmp/ups.1 |
  11. htmlfmt >/tmp/ups.2
  12. sam -d /tmp/ups.2 >[2] /dev/null <<'!'
  13. /^Tracking results.*/p
  14. .,$d
  15. /Help/d
  16. 1,.d
  17. $-2,$d
  18. /Status:/+1
  19. .,/«TR»/-2d
  20. ,s/\n/ /g
  21. ,s/«TR»/\n/g
  22. ,s/«TD»/ /g
  23. ,s/ * */ /g
  24. ,s/^[ ]*//g
  25. ,s/[ ]*$//g
  26. ,s/\n\n+/\n\n/g
  27. ,p
  28. !
  29. echo