2

我正在执行 open 3,如下所示我从 SYSOUT 的 sysout 获得以下行

   <May 7, 2013 1:21:59 AM IST> <Info> <Security> <BEA-090905> <Disabling CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true> 
    <May 7, 2013 1:21:59 AM IST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG to FIPS186PRNG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true> 
    <May 7, 2013 1:21:59 AM IST> <Notice> <Security> <BEA-090898> <Ignoring 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: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.> 

我预期的字符串

<Composites>
    i=0
    compositedetail=swlib:soaprov/soacomposite=eis/FileAdapter#eis/FileAdapter#
    swlib:soaprov/soacomposite=eis/FileAdapter#eis/FileAdapter# starts with swlib
    </Composites>

我想忽略 BEA 安全中的行,只打印我预期的字符串。我该怎么做?

我的 $command = $java 。'-类路径'。$类路径。' ' 。$sec 选项。' ' 。$类名。' ' 。$服务网址。' ' 。$复合材料;

 local (*HANDLE_IN, *HANDLE_OUT, *HANDLE_ERR);

      my $pid = open3( *HANDLE_IN, *HANDLE_OUT, *HANDLE_ERR, "$command") ;
     my $nextLine;
    while(<HANDLE_OUT>) {       
        $nextLine= $_;  
        print $nextLine;


}
4

1 回答 1

1

你可以使用正则表达式来做到这一点。当然,您也可以使用某种 xml 解析器,但在这种情况下,这将是一种矫枉过正。

my $debug = 1;#set 1 for debugging
while(my $nextLine=<HANDLE_OUT>) {       
      chomp($nextLine);  
      if ($nextLine =~ m!<BEA-!){
           print "Skipping this line (BEA): |$nextLine|\n" if $debug;
        }
        print $nextLine."\n";
于 2013-05-14T09:51:02.210 回答