Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

cmd.exe piping stress

by tomazos (Deacon)
on Mar 20, 2006 at 14:29 UTC ( [id://537953]=perlquestion: print w/replies, xml ) Need Help??

tomazos has asked for the wisdom of the Perl Monks concerning the following question:

Under Windows the result of:

C:/> perl a.pl | perl b.pl

differs from

C:/> perl a.pl > f C:/> perl b.pl < f

The specific example is:

D:\tmp3>perl units.pl COM1 < dmp4.tests | perl unit2summary.pl : test selftest randunit : test selftest ok # includes all except errors and warnings : test selftest # includes all except errors : test selftest all # includes also errors and warnings : mc creation : mc attr : mc resdata : mc container : mc clone 1 (11.1111111111111%) TENTATIVE D:\tmp3>perl units.pl COM1 < dmp4.tests > dmp4.results D:\tmp3>perl unit2summary.pl < dmp4.results PASSED: test selftest randunit PASSED: test selftest ok # includes all except errors and warnings TENTATIVE: test selftest # includes all except errors FAILED: test selftest all # includes also errors and warnings PASSED: mc creation FAILED: mc attr PASSED: mc resdata PASSED: mc container PASSED: mc clone TESTS: 9 PASSED 6 (66%) TENTATIVE 1 (11%) FAILED 2 (22%) D:\tmp3>

I can't explain it. The only difference I see is when I print out multiple local my variables in one print, the characters get corrupted somehow.

Has anyone seen something like this before?

Any ideas about how to proceed with debugging, I'm stumped.

Could it have something to do with cygwin perl? I have both cygwin perl and activestate installed on my machine.

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com

Replies are listed 'Best First'.
Re: cmd.exe piping stress
by BrowserUk (Patriarch) on Mar 20, 2006 at 16:28 UTC
    Any ideas about how to proceed with debugging,

    To see what is being received from the pipe, use a one-liner to receive and redirect it:

    perl units.pl COM1 < dmp4.tests > dmp4.results perl units.pl COM1 < dmp4.tests | perl -pe1 > dmp4.piped diff dmp4.results dmp4.piped

    Then you can compare the two.

    What are those COM1 references doing?

    The comments mention warnings and errors. You are only piping/redirecting STDOUT not STDERR? Not that it should make any difference in what gets redirected or piped as STDERR would get displayed on the console in both cases--unless you are redirecting stuff internally to the program? To the serial port for example?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Th dmp4.results and the dmp4.piped are identical.

      When I then go and run:

      C:/> perl unit2summary.pl < dmp4.piped

      It works.

      When however I run it with "perl units.pl COM1 | perl unit2summary.pl" it doesn't work.

      The COM1 identifies the com port. It is part of a basic unit testing framework for a consumer electronics device.

      The code for unit2summary.pl follows:

      #!perl use strict; use warnings; my %results = (); my $total; my $command = ''; my $result = ''; while (<STDIN>) { chomp; next if /^\s*$/; if (/^COMMAND:\s+(.*)$/) { $command = $1; } if (/^RESULT:\s+(.*)$/) { $result = $1; print "$result: $command \n"; $results{$result}++; $total++; } } print "\n"; print "TESTS: $total "; foreach (keys %results) { print "$_: " . $results{$_} . " (" . abs($results{$_} * 100 / $tot +al) . "%) "; } print "\n";

      A sample of the dmp4.piped follows:

      COMMAND: mc creation TIMEOUT: 3 Creating various ContentData objects SUCCESS: Up-Casting HMediaAudioCD to HMediaCD SUCCESS: Up-Casting HMediaImageCD to HMediaCD SUCCESS: Up-Casting HMediaVideoCD to HMediaCD Working with const ContentData objects SUCCESS: Creation of new const-pointer HMediaAudioCD initialized w +ith non-const handle SUCCESS: Up-casting constHMediaAudioCD to constHMediaCD SUCCESS: Const-Casting from constHMediaAudioCD to HMediaAudioCD SUCCESS: Down-casting from constHMediaCD to constHMediaAudioCD SUCCESS: Making Const from cpHACDconst to ccpCD not successful RETURN: RESULT: PASSED COMMAND: mc attr TIMEOUT: 3 Creating HMediaAudioCD and add Title Attribute SUCCESS: HMediaAudioCD created SUCCESS: Checking for attribute "title" ERROR: Checking attribute value: This is my lif Changing value of Title attribute by re-adding with different valu +e SUCCESS: Checking for attribute "title" (2nd time) SUCCESS: Checking if attribute value was updated SUCCESS: Checking No. of attributes: 1 SUCCESS: Re-Checking No. of attributes: 1 SUCCESS: Removing attribute ERROR: Checking if attribute was really removed Adding more attributes SUCCESS: Attribute 0 has value A SUCCESS: Attribute 1 has value B SUCCESS: Attribute 2 has value C SUCCESS: Attribute 3 has value D SUCCESS: Attribute 4 has value E SUCCESS: Removing attribute at index 1 in list SUCCESS: Trying to remove non-existing attribute at index 5 ERROR: Removing all 4 Attributes: 4 elements left Checking setAttributeValue methods SUCCESS: Checking if setting value by name on non existing attribu +te prohibited SUCCESS: Checking if setting value by index on non existing attrib +ute prohibited SUCCESS: Setting value to new attribute SUCCESS: Re-setting value of existing attribute at index 0 Testing const char* - interface Adding attribute using const char* interface SUCCESS: Getting value of just added attribute SUCCESS: Checking if value of attribute is correct: somewhere over + the rainbow SUCCESS: Re-setting value of just added attribute using const char +* interface SUCCESS: Getting value of just changed attribute SUCCESS: Checking if value of attribute is correct: somewhere over + the rainbow RETURN: RESULT: FAILED

      Any help appreciated.

      -Andrew.


      Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
        C:/> perl unit2summary.pl < dmp4.piped

        Can I take it from the prompt shown in your command line that you are using some other shell than cmd.exe?

        If so, try your commands with cmd.exe. I can't see any difference in the behaviour here:

        C:\test>perl -pe1 junk.dat | perl unit2summary.pl PASSED: mc creation FAILED: mc attr TESTS: 2 PASSED: 1 (50%) FAILED: 1 (50%) C:\test>perl unit2summary.pl <junk.dat PASSED: mc creation FAILED: mc attr TESTS: 2 PASSED: 1 (50%) FAILED: 1 (50%)

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: cmd.exe piping stress
by ikegami (Patriarch) on Mar 20, 2006 at 15:46 UTC
    I don't know, but I mgiht be able to find out if I had some code to try...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://537953]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-12-13 02:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (67 votes). Check out past polls.