Blame awklib/eg/network/urlchk.awk

Packit 575503
BEGIN {
Packit 575503
  if (ARGC != 2) {
Packit 575503
    print "URLCHK - check if URLs have changed"
Packit 575503
    print "IN:\n    the file with URLs as a command-line parameter"
Packit 575503
    print "    file contains URL, old length, new length"
Packit 575503
    print "PARAMS:\n    -v Proxy=MyProxy -v ProxyPort=8080"
Packit 575503
    print "OUT:\n    same as file with URLs"
Packit 575503
    print "JK 02.03.1998"
Packit 575503
    exit
Packit 575503
  }
Packit 575503
  URLfile = ARGV[1]; ARGV[1] = ""
Packit 575503
  if (Proxy     != "") Proxy     = " -v Proxy="     Proxy
Packit 575503
  if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort
Packit 575503
  while ((getline < URLfile) > 0)
Packit 575503
     Length[$1] = $3 + 0
Packit 575503
  close(URLfile)      # now, URLfile is read in and can be updated
Packit 575503
  GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk "
Packit 575503
  for (i in Length) {
Packit 575503
    GetThisHeader = GetHeader i " 2>&1"
Packit 575503
    while ((GetThisHeader | getline) > 0)
Packit 575503
      if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0
Packit 575503
    close(GetThisHeader)
Packit 575503
    print i, Length[i], NewLength > URLfile
Packit 575503
    if (Length[i] != NewLength)  # report only changed URLs
Packit 575503
      print i, Length[i], NewLength
Packit 575503
  }
Packit 575503
  close(URLfile)
Packit 575503
}