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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.