summaryrefslogtreecommitdiff
path: root/rc/bin/ups
blob: e1ad56ca6ef28b71c98ca10bbef85420693d5ca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/rc
# ups - look up a UPS tracking number
rfork en

if(! ~ $#* 1) {
	echo usage: ups 1ZA41W190338680961 >[1=2]
	exit usage
}

hget 'http://wwwapps.ups.com/WebTracking/processInputRequest?tracknum='^$1^ \
	'&TypeOfInquiryNumber=T' >/tmp/ups.1

sed 's/<[Tt][Dd]>/& «TD»/g; s/<[Tt][Rr]>/&<td> «TR» /g' /tmp/ups.1 |
	htmlfmt >/tmp/ups.2
sam -d /tmp/ups.2 >[2] /dev/null <<'!'
/^Tracking results.*/p
.,$d
/Help/d
1,.d
$-2,$d
/Status:/+1
.,/«TR»/-2d
,s/\n/ /g
,s/«TR»/\n/g
,s/«TD»/	/g
,s/ *	 */	/g
,s/^[ 	]*//g
,s/[ 	]*$//g
,s/\n\n+/\n\n/g
,p
!
echo