robdcb
June 16, 2010, 10:51am
1
Hi all,
Is it possible to create an script that parse an snoop output similar to the example above ? Each line is ended by "$" (set list in vi). as a result, I would like to print the output in only one line.
can someone give me some tip ?
Thanks a lot .
l version="1.0"
encoding="UTF-8"
?><soapenv:Envel
ope xmlns:soapen
v="http://schema
s.xmlsoap.org/so
ap/envelope/" xm
lns:xsd="http://
www.w3.org/2001/
XMLSchema" xmlns
:xsi="http://www
.w3.org/2001/XML
Schema-instance"
>
Something like this ?
$
$ cat f2
l version="1.0"
encoding="UTF-8"
?><soapenv:Envel
ope xmlns:soapen
v="http://schema
s.xmlsoap.org/so
ap/envelope/" xm
lns:xsd="http://
www.w3.org/2001/
XMLSchema" xmlns
:xsi="http://www
.w3.org/2001/XML
Schema-instance"
>
$
$ perl -lne 'printf; END{print}' f2
l version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
$
$
tyler_durden
robdcb
June 16, 2010, 1:08pm
3
Almost like this, but when I tried to run your script,the lines are not separeted, as you can see on the example above.
I need to have the output separeted by lines. Is it possible ?
Thanks so much !
LH-MIRT -> 10.31.204.32 TCP D=50520 S=50310 Push Ack=4059676919 Seq=3849670225 Len=202 Win=49232 Options=<nop,nop,tstamp 1195815396
3278302158>....GF...f..HTTP/1.1 200 OK..Expires: Thu, 01 Jan 1970 00:00:00 GMT..Set-Cookie:JSESSIONID=pokklc1vhe40;Path=/axis..Cont
ent-Type: text/xml; charset=utf-8..Transfer-Encoding: chunked..Server: Jetty(6.1.18)....25D..LH-MIRT -> 10.31.204.32 TCP D=50520 S=
50310 Push Ack=4059676919 Seq=3849670427 Len=607 Win=49232 Options=<nop,nop,tstamp 1195815396 3278302158>
I don't think I understood.
Can you post
(a) your input data and
(b) the desired output ?
If your "snoop" data is in a file then post the result of this command -
cat -n <your_snoop_data_file>
And then show us what you want it to look like.
tyler_durden
robdcb
June 16, 2010, 3:44pm
5
This is an example of what I do receive:
.....$;.GF..POST
/axis/services/
PiContentProvide
r HTTP/1.1..Cont
ent-Type: text/x
ml; charset=UTF-
8..SOAPAction: "
transactio
n"..User-Agent:
Java1.5.0_14..Ho
st: 10.10.14.3
4:50300..Accept:
text/html, imag
e/gif, image/jpe
g, *; q=.2, */*;
q=.2..Connectio
n: Keep-Alive..C
ontent-Length: 7
03....
.....$;.GF..<?xm
l version="1.0"
encoding="UTF-8"
?>.<soapenv:Enve
lope xmlns:soape
nv="http://schem
as.xmlsoap.org/s
oap/envelope/"><
soapenv:Header x
mlns:efet="http:
//sb.airenet/x
sd/RealizarDebito
SemReservaSaldoO
PQRequest"/>
This is the output that I need:
.....$;.GF..POST/axis/services/PiContentProvider HTTP/1.1..Content-Type: text/xml; charset=UTF-8..SOAPAction: "transaction"..User-Agent: Java1.5.0_14..Host: 10.10.14.34:50300..Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2..Connection: Keep-Alive..Content-Length: 703....
.....$;.GF..<?xml version="1.0" encoding="UTF-8"?>.<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:efet="http://sb.airenet/xsd/RealizarDebitoSemReservaSaldoOPQRequest"/>
Thanks, the problem is clearer now.
Try this -
$
$
$ cat -n f3
1 .....$;.GF..POST
2 /axis/services/
3 PiContentProvide
4 r HTTP/1.1..Cont
5 ent-Type: text/x
6 ml; charset=UTF-
7 8..SOAPAction: "
8 transactio
9 n"..User-Agent:
10 Java1.5.0_14..Ho
11 st: 10.10.14.3
12 4:50300..Accept:
13 text/html, imag
14 e/gif, image/jpe
15 g, *; q=.2, */*;
16 q=.2..Connectio
17 n: Keep-Alive..C
18 ontent-Length: 7
19 03....
20
21
22 .....$;.GF..<?xm
23 l version="1.0"
24 encoding="UTF-8"
25 ?>.<soapenv:Enve
26 lope xmlns:soape
27 nv="http://schem
28 as.xmlsoap.org/s
29 oap/envelope/"><
30 soapenv:Header x
31 mlns:efet="http:
32 //sb.airenet/x
33 sd/RealizarDebito
34 SemReservaSaldoO
35 PQRequest"/>
$
$ perl -ne 'chomp; if (/^(\.)+\$;.GF/ and $.>1){print "\n\n",$_} elsif (/./){printf} END{print "\n"}' f3
.....$;.GF..POST/axis/services/PiContentProvider HTTP/1.1..Content-Type: text/xml; charset=UTF-8..SOAPAction: "transaction"..User-Agent:Java1.5.0_14..Host: 10.10.14.34:50300..Accept:text/html, image/gif, image/jpeg, *; q=.2, */*;q=.2..Connection: Keep-Alive..Content-Length: 703....
.....$;.GF..<?xml version="1.0"encoding="UTF-8"?>.<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:efet="http://sb.airenet/xsd/RealizarDebitoSemReservaSaldoOPQRequest"/>
$
$
tyler_durden