%!ps % find404a.psl % Preliminary trapping of logfile 404 lines % ========================================= % by Don Lancaster % Copyright c 2009 and earlier by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is optional for this program. % After obvious location mods, uncomment ONE of the following two lines: % (C:\\gonzo2\\gonzo.ps)run % use internal gonzo % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % Gonzo is available as http://www.tinaja.com/post01.asp#gonzo with a % tutorial at http://www.tinaja.com/glib/gonzotut.pdf %%%%%%%%%%%%% % This is the preliminary development code for the Fatcow log files. % Initial goals are reading main and trapping 404. % At present, input, output, and program files must be in the same folder. % Note that an "Empty Job - No File Produced" is normal and expected. % An excerpt from the Gonzo Utilities.... % mergestr merges the two top stack strings into one top stack string /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % version "r" creates unsorted array. /array404unsorted [ [ (/name) 0 ] ] store /proc1 { /curline exch store /oktowrite true store curline ( 404 ) search { /pre exch store pop /post exch store /pre pre (") search {pop pop /pre exch store } % remove up to "GET {oktowrite false store} ifelse /pre pre ( ) search {pop pop /pre exch store } % remove GET " {oktowrite false store} ifelse /pre pre (") search {/pre exch store pop pop } % remove trailing " {oktowrite false store} ifelse /pre pre ( ) search {/pre exch store pop pop} % remove HTML... {oktowrite false store} ifelse % switch to post strings /post post (") search {pop pop /post exch store } % remove up to first " {oktowrite false store} ifelse /post post (") search {/post exch store pop pop } % remove beyond first remaining " {oktowrite false store} ifelse % write residue oktowrite { writefile pre writestring writefile ( ) writestring writefile post writestring writefile (\n\n) writestring /reportcount reportcount 1 add store mark array404unsorted aload pop mark pre 1000 string cvs 1 ] ] /array404unsorted exch store } if } if } store /firstfind404s { /readfilename fileheader infilename mergestr store /readfile readfilename (r) file store /writefilename fileheader outfilename mergestr store /writefile writefilename (w+) file store /linestring 10000 string store % length of input string /reportcount 0 store 0 1 100000 { % for a bunch of lines readfile linestring readline {proc1}{exit} ifelse } for writefile (\n\n\nTotal reports ---> ) writestring writefile reportcount 10 string cvs writestring writefile (\n\n\n) writestring readfile closefile writefile closefile } store %%%%%%%%%%%%%%%%%% demo - remove or alter before reuse %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % /fileheader (C:\\Documents and Settings\\don 2\\Desktop\\log_play\\)def /infilename (moo.tinajacom)def /outfilename (current404.psl) def firstfind404s array404unsorted {==} forall % now try old bubble sort modified for first array element (\n\n\n\n\n) print flush /popbubblesort2s { /curmat1 exch store curmat1 length 1 sub -1 1 {curmat1 0 get exch 1 exch 1 exch {/posn exch store curmat1 posn get 2 copy 1 pop 0 get exch 1 pop 0 get lt {exch} if curmat1 exch posn 1 sub exch put} for curmat1 exch posn exch put } for curmat1 } bind store array404unsorted popbubblesort2s array404unsorted {==} forall %%%%%%%%% make a countarray %%%%%%%%% /countarray [[ (dummy) 0] ] store /bumpcount {array404unsorted posn get 1 get 1 add /newcount exch store array404unsorted posn 1 sub get 1 newcount put } store /keep {mark countarray aload pop array404unsorted posn get ] /countarray exch store } store array404unsorted length 1 sub -1 1 {/posn exch store array404unsorted posn get 0 get array404unsorted posn 1 sub get 0 get eq dup == {bumpcount}{keep} ifelse } for (\n\n\n) print flush countarray {==} forall % resort on count /popbubblesort2sc { /curmat1 exch store curmat1 length 1 sub -1 1 {curmat1 0 get exch 1 exch 1 exch {/posn exch store curmat1 posn get 2 copy 1 get exch 1 get lt {exch} if curmat1 exch posn 1 sub exch put} for curmat1 exch posn exch put } for curmat1 } bind store countarray popbubblesort2sc % sort by count (\n\n\n) print flush countarray {==} forall (\n\nTotal reports -----------> ) print flush reportcount 10 string cvs == (\n\nReports after combining --> ) print flush countarray length 10 string cvs == (\n\nUnique combined reports ---> ) print flush countarray length 10 string cvs == % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % EOF