- Where Developers Learn, Share, & Build Careers
For the purpose of debugging I need to divide a query string in several infinitely:
Output comes from Tishark and its purpose is to debug Google Analytics events so that the output looks like this:
82.387501 Humpus -> Domain.net 1261 GET /__utm.gif?utmwv=5.3.7&utms=22&utmn=1234&utmhn=domain.com&utmt=event&utme=5(x*y*z%2Fstart%2Fklipp%2F166_SS% 20example) (10) and UTMCs = UTF-8 ~ HTTP / 1.1 What I want is a more human readable version:
utmhn: domain .com Utmt: Event Usage: 5 (x * y * z / start / klipp / 166_SS / example) (10) utmcs: UTF-8 or better: < Pre> utmhn: domain.com utmt: Event Usage: 5 (xyz / start / klipp / 166_SS / example) (10) utmcs: UTF-8 But 'this purpose I do not get my head around SAD (or awk) ...
Another way to use a Pearl:
#! Use / usr / bin / perl -l strict; Use warnings; While (<< lb; & gt;) Mine ($ qs) = m /. *? GET *? \? (\ S +) \ s /; My @ cross = partition (/ [& amp;;] /, $ qs); Prefer my $ pair (@ear) (my ($ name, $ value) = partition (/ = /, $ pair); if ($ name eq 'utme') {$ value = ~ s! (% 2F | % 20)! /! G; $ Value = ~ s! \ *! \ N \ t \ t! G; $ Value = ~ s! \ (! (\ N \ t \ t! $ Value = ~ s / \ ) \ (/ \ N \ t) (/;} #Unnesap stuff of URI $ value = ~ s /% ([A-FA-F 0-9] [A-FA-F-0] / pack ( "C", hex ($ 1) / for example; if ($ name eq 'utmhn') {print "$ name: print" \ n ";} < / Code> strong> output
utmhn: domain.com utmwv: 5.3.7 utms: 22 utmn: 1234 utmt: event usage: 5 (xyz / start / Klipp / 166_SS / example) (10) utmcs: UTF-8 Usage tshark ...... / Script.pl gain < Li> I care about showing utmhn: domain.com on the first line -
Comments
Post a Comment