diff --git a/waccess b/waccess index cd7c25e..cded023 100755 --- a/waccess +++ b/waccess @@ -2,7 +2,7 @@ # waccess - Copyright (c) 2001,2002, TundraWare Inc., All Rights Reserved -VERSION = "$Id: waccess,v 1.68 2002/09/03 19:34:03 tundra Exp $" +VERSION = "$Id: waccess,v 1.69 2002/09/03 20:20:37 tundra Exp $" # # Look for selected strings passed on the command line in the http access log. @@ -32,7 +32,7 @@ # be partial IP quads. If IGNOREDFILE exists, its contents will # be appended to the IGNORED data structure at program startup. -IGNORED = ["127.0", ] +IGNORED = [] IGNOREDFILE = os.path.join(os.getenv("HOME"), ".waccessignored") @@ -74,21 +74,33 @@ ########## -# Print program version number and exit normally -########## - -def version(): - print VERSION - sys.exit(0) - - -########## # Print program usage information and error exit. ########## def usage(): - print "usage: waccess [-acilqrsv -f logfile]" - sys.exit(2) + UsageInfo = ( + ("waccess " + VERSION.split()[2] + + " - Copyright (c) 2001, 2002 TundraWare Inc., All Rights Reserved. \n", ""), + (" usage: waccess [-achilqrsv] [-f logfile] [search-key...] where,\n\n", ""), + ("-a", "Sort summary output alphabetically by search key\n"), + ("-c", "Ignore case when checking for key match in access record\n"), + ("-d logfile", "Name of logfile to use. Default is /var/log/httpd-access.log\n"), + ("-h", "Display this help information\n"), + ("-i", "Do not ignore any addresses\n"), + ("-l", "List ignored addresses in summary output\n"), + ("-q", "Quiet mode - suppresses summary output\n"), + ("-r", "Do reverse addess lookups on each matching record\n"), + ("-s", "Only show summary output - do not display individual matching records\n"), + ("-v", "Show detailed version information\n"), + ("seach-key...", "Strings to look for in each access record\n\n") + ) + + for x, y in UsageInfo: + if len(x) < 20: # Only indent for the actual argument info + sys.stdout.write(10 * " ") + sys.stdout.write(x) + sys.stdout.write((20 - len(x)) * " ") + sys.stdout.write(y) @@ -109,6 +121,8 @@ opts, args = getopt.getopt(sys.argv[1:], '-acf:ilqrsv') except getopt.GetoptError: usage() + sys.exit(2) + for opt, val in opts: if opt == "-a": @@ -117,6 +131,9 @@ IGNORECASE = TRUE if opt == "-f": LOG = val + if opt == "-h": + usage() + sys.exit(0) if opt == "-i": NOIGNORE = TRUE if opt == "-l": @@ -130,7 +147,9 @@ SHOW = FALSE REVERSE = FALSE if opt == "-v": - version() + print VERSION + sys.exit(0) + ########## @@ -199,6 +218,8 @@ if MATCHED: if REVERSE: revname = IPReverse(IPADR) + else: + revname = "" if SHOW: print DATESTAMP, " " * (19 - len(DATESTAMP)), \