1
0

fedex 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/rc
  2. if(! ~ $#* 1) {
  3. echo usage: fedex 123456789012 >[1=2]
  4. exit usage
  5. }
  6. rfork e
  7. fn bgrep{
  8. pattern=`{echo $1 | sed 's;/;\\&;'}
  9. shift
  10. @{ echo 'X {
  11. $
  12. a
  13. .
  14. }
  15. X ,x/(.+\n)+\n/ g/'$pattern'/p' |
  16. sam -d $* >[2]/dev/null
  17. }
  18. }
  19. fn awk2 {
  20. awk 'NR%2==1 { a=$0; }
  21. NR%2==0 { b=$0; printf("%-30s %s\n", a, b); }
  22. ' $*
  23. }
  24. fn awk3 {
  25. awk '{line[NR] = $0}
  26. END{
  27. i = 4;
  28. while(i < NR){
  29. what=line[i++];
  30. when=line[i];
  31. comment="";
  32. if(!(when ~ /..\/..\/.... ..:../)){
  33. # out of sync
  34. printf("%s\n", what);
  35. continue;
  36. }
  37. i++;
  38. if(!(line[i+1] ~ /..\/..\/.... ..:../) &&
  39. (i+2 > NR || line[i+2] ~ /..\/..\/.... ..:../)){
  40. what = what ", " line[i++];
  41. }
  42. printf("%s %s\n", when, what);
  43. }
  44. }' $*
  45. }
  46. # hget 'http://www.fedex.com/cgi-bin/track_it?airbill_list='$1'&kurrent_airbill='$1'&language=english&cntry_code=us&state=0' |
  47. hget 'http://www.fedex.com/cgi-bin/tracking?action=track&language=english&cntry_code=us&initial=x&mps=y&tracknumbers='$1 |
  48. htmlfmt >/tmp/fedex.$pid
  49. sed -n '/Tracking number/,/^$/p' /tmp/fedex.$pid | awk2
  50. echo
  51. sed -n '/Reference number/,/^$/p' /tmp/fedex.$pid | awk2
  52. echo
  53. sed -n '/Date.time/,/^$/p' /tmp/fedex.$pid | sed 1,4d | fmt -l 4000 | sed 's/ [A-Z][A-Z] /&\n/g'
  54. rm /tmp/fedex.$pid