I am running Win7 and using Strawberry Perl. I am trying to use tshark (the tshark command works from the command line fine) and perl to 'dechunk' the 1 to 3 DIAMETER messages that can be included in a single TCP frame into separate rows in the output file. I get an 'tshark illegal command' message. The error I get is "tshark: An error occurred while printing packets: Invalid argument" This suggests the problem is the 'pipe' operator on line 41 - the '$tsharkcmd .= " -r $input |";' line since this is the only difference from executing the command manually. I cannot seem to find any information on what to replace this with so it will work on a Windows system.
use strict; # # extract DIAMETER chunks into separate rows in a file for analysis # this version for TCP based DIAMETER interfaces (SWx, STa, Gx, Gxa, S +6b # my %columns = ( # frame 0=>"frame.time", 1=>"frame.number", 2=>"frame.len", 3=>"ip.src", 4=>"tcp.srcport", 5=>"ip.dst", 6=>"tcp.dstport", # data 7=>"diameter.applicationId", 8=>"diameter.Session-Id", 9=>"diameter.Origin-Host", 10=>"diameter.Destination-Host", 11=>"diameter.User-Name", 12=>"diameter.cmd.code", 13=>"diameter.flags.request", 14=>"diameter.flags.T", 15=>"diameter.Result-Code", ); print "Start: ", time(), "\n"; my $et = time(); my $framecounter; my $chunkcounter; # input and output files my $input = $ARGV[0]; my $output = $input . ".txt"; my $tsharkcmd = q[c:/progra~1/wireshark/tshark.exe -n -2 -t e -T field +s]; foreach (sort {$a <=> $b} keys %columns) { $tsharkcmd .= " -e $columns{$_}"; } $tsharkcmd .= " -r $input |"; print "\n", $tsharkcmd, "\n\n"; # open filehandles open OUT, ">$output" or die "cannot open $output: $!\n"; open TSHARK, $tsharkcmd or die "cannot open tshark: $!\n"; # dechunking starts here # print "\nFinished: ", time(), "\n"; $et = time() - $et; print "elapsed time: $et\n"; my $fps = $framecounter / $et; my $cps = $chunkcounter / $et; print "frames processed: $framecounter ($fps/sec)\n"; print "chunks processed: $chunkcounter ($cps/sec)\n";
In reply to pipe operator for windows by paidcritic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |