http://www.perlmonks.org?node_id=1033462

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

I am executing open 3 as shown below I am getting below lines from sysout from SYSOUT
<May 7, 2013 1:21:59 AM IST> <Info> <Security> <BEA-090905> <Disabl +ing CryptoJ JCE Provider self-integrity check for better startup perf +ormance. To enable this check, specify -Dweblogic.security.allowCrypt +oJDefaultJCEVerification=true> <May 7, 2013 1:21:59 AM IST> <Info> <Security> <BEA-090906> <Chang +ing the default Random Number Generator in RSA CryptoJ from ECDRBG to + FIPS186PRNG. To disable this change, specify -Dweblogic.security.all +owCryptoJDefaultPRNG=true> <May 7, 2013 1:21:59 AM IST> <Notice> <Security> <BEA-090898> <Ign +oring the trusted CA certificate "CN=CertGenCA,OU=FOR TESTING ONLY,O= +MyOrganization,L=MyTown,ST=MyState,C=ka". The loading of the trusted +certificate list raised a certificate parsing exception PKIX: Unsuppo +rted OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
My expected string
<Composites> i=0 compositedetail=swlib:soaprov/soacomposite=eis/FileAdapter#eis/Fil +eAdapter# swlib:soaprov/soacomposite=eis/FileAdapter#eis/FileAdapter# starts + with swlib </Composites>
I want to ignore the lines from BEA security and print only my expected string at once.I want to print my expecting string at once not line by line ignoring BEA warnings How can i do it?
my $command = $java . ' -classpath ' . $classpath . ' ' . $secOptions +. ' ' . $className . ' ' . $serviceUrl . ' ' . $composites; local (*HANDLE_IN, *HANDLE_OUT, *HANDLE_ERR); my $pid = open3( *HANDLE_IN, *HANDLE_OUT, *HANDLE_ERR, "$command +") ; my $nextLine; while(<HANDLE_OUT>) { $nextLine= $_; }

Replies are listed 'Best First'.
Re: neglect warnings in open 3 HANDLE_OUT
by RichardK (Parson) on May 14, 2013 at 14:09 UTC

    Didn't you ask this question before?

    Those messages are coming out of the java you called, so why don't you do what they are telling you to do? (i.e. set those -D symbols). Then it will stop complaining and you wont miss any import error messages.

      Can you please let me know what to set .I dont think I cannot set -D to all the warnings ?
Re: neglect warnings in open 3 HANDLE_OUT
by kennethk (Abbot) on May 14, 2013 at 13:51 UTC
    You don't show the part of the code that does the printing, so it's difficult to say how you should modify it in order to avoid your unwanted output. If you can clearly delineate what makes a line a "BEA warning" or not, then you could skip them perhaps w/ Loop Control:
    while(<HANDLE_OUT>) { next if /<BEA-\d+>/; $nextLine= $_;

    This of course assumes that the warnings in question are being emitted on STDOUT and not STDERR.

    If this solution is not what you are looking for, provide us with the entire STDOUT stream from your system call and the desired output from your program, as well as the entire block of read-and-output code that is presently not working for you.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      My output stream
      <May 7, 2013 1:21:59 AM IST> <Info> <Security> <BEA-090905> <Disabl +ing CryptoJ JCE Provider self-integrity check for better startup perf +ormance. To enable this check, specify -Dweblogic.security.allowCrypt +oJDefaultJCEVerification=true> <May 7, 2013 1:21:59 AM IST> <Info> <Security> <BEA-090906> <Chang +ing the default Random Number Generator in RSA CryptoJ from ECDRBG to + FIPS186PRNG. To disable this change, specify -Dweblogic.security.all +owCryptoJDefaultPRNG=true> <May 7, 2013 1:21:59 AM IST> <Notice> <Security> <BEA-090898> <Ign +oring the trusted CA certificate "CN=CertGenCA,OU=FOR TESTING ONLY,O= +MyOrganization,L=MyTown,ST=MyState,C=ka". The loading of the trusted +certificate list raised a certificate parsing exception PKIX: Unsuppo +rted OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.> <Composites> i=0 compositedetail=swlib:soaprov/soacomposite=eis/FileAdapter#eis/Fil +eAdapter# swlib:soaprov/soacomposite=eis/FileAdapter#eis/FileAdapter# starts + with swlib </Composites>
      I want to print only below lines at single go not line by line
      <Composites> i=0 compositedetail=swlib:soaprov/soacomposite=eis/FileAdapter#eis/Fil +eAdapter# swlib:soaprov/soacomposite=eis/FileAdapter#eis/FileAdapter# starts + with swlib </Composites>
      I am using backtick I want to parse this. print `$command`;
        Perhaps I just don't understand what you mean by "at single go"; given that your output stream is naturally new-line delimited, I fail to see the problem encountered by:
        while(<HANDLE_OUT>) { next if /<BEA-\d+>/; next if !/\S/; print; }
        which is pretty much what I posted above.

        Update: And then this node's parent added

        I am using backtick I want to parse this. print `$command`;
        Are you using IPC::Open3 or are you using backticks? For the latter, you would presumably need to capture the output filter it, probably by splitting on new-lines and feeding it through the loop above.

        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: neglect warnings in open 3 HANDLE_OUT
by hippo (Bishop) on May 14, 2013 at 14:12 UTC
      The problem is I am new to perl I am trying myself and not getting solution hence have asked in some forums.
        perl is the program; Perl is the language.

        Everyone was new once, but you should be aware that cross-posting is considered incredibly rude. Your Stack Overflow post is only 5 hours old, and does in fact have a proposed solution. Work with the person who already volunteered to help you; why doesn't their solution work for you?


        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.