Debian Codegraph @

awklib/eg/network/urlchk.awk

raw
1 BEGIN {
2 if (ARGC != 2) {
3 print "URLCHK - check if URLs have changed"
4 print "IN:\n the file with URLs as a command-line parameter"
5 print " file contains URL, old length, new length"
6 print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080"
7 print "OUT:\n same as file with URLs"
8 print "JK 02.03.1998"
9 exit
10 }
11 URLfile = ARGV[1]; ARGV[1] = ""
12 if (Proxy != "") Proxy = " -v Proxy=" Proxy
13 if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort
14 while ((getline < URLfile) > 0)
15 Length[$1] = $3 + 0
16 close(URLfile) # now, URLfile is read in and can be updated
17 GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk "
18 for (i in Length) {
19 GetThisHeader = GetHeader i " 2>&1"
20 while ((GetThisHeader | getline) > 0)
21 if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0
22 close(GetThisHeader)
23 print i, Length[i], NewLength > URLfile
24 if (Length[i] != NewLength) # report only changed URLs
25 print i, Length[i], NewLength
26 }
27 close(URLfile)
28 }