I was able to fix this problem!! Woo Hoo! Thanks everyone for the responses and inputs

Using "qx" instead of backticks and adding "2>&1" at the end of the PGP command did the trick. Below is the modified script

#!/pgp/perl5/bin/perl ##Sample script to grep perl program output use warnings; use strict; use feature qw{ say }; #Added env variable for exporting pgp LIB_PATH $ENV{LIBPATH} = "/xyz/lib"; my $program_output3 = qx(pgp --options --verbose 2>&1); if($program_output3 !~ /0:file wiped successfully/i) { print "Something went wrong\n"; print "$program_output3\n"; if($program_output3 =~ /3013:no keys found/i) { print "Customer key is not found. Cannot encrypt\n"; } elsif($program_output3 =~ /3090:operation failed, file not found/i +) { print "File is not found. Check the path again\n"; } elsif($program_output3 =~ /1080:no private key could be found for +decryption/i) { print "Private key not found on our keyring.\n"; } elsif($program_output3 =~ /3001:input file not found/i) { print "File is not found?\n"; } elsif($program_output3 =~ /1053:signing key not found/i) { print "Signing key to encrypt is not found in the keyring\n"; } elsif($program_output3 =~ /3011:invalid passphrase specified/i) { print "Check the passphrase used. \n"; } elsif($program_output3 =~ /3083:could not create output file/i) { print "Check if the output location is valid or has access per +missions\n"; } elsif($program_output3 =~ /3028:multiple inputs cannot be sent to +a single output file/i) { print "This is a weird one. Check if there are any wildcards i +n the filename or command\n"; } } else { print "$program_output3\n"; print "Command ran successfully\n"; }

Below are sample outputs from the commands

########### RUN 1 ################### /pgp/scripts->./error_checker.pl pgp:encrypt (3157:current local time 2016-09-22T17:15:21-04:00) /pgp/.pgp/pubring.pkr:open keyrings (1006:public keyring) /pgp/.pgp/secring.skr:open keyrings (1007:private keyring) 0x3279584E:encrypt (1030:key added to recipient list) 0x4B3DBEBE:encrypt (1050:key added as signer) /pgp/scripts/sample.txt:encrypt (3048:data encrypted with cipher AES-2 +56) /pgp/scripts/sample.txt:encrypt (0:output file /pgp/scripts/sample.txt +.pgp) /pgp/scripts/sample.txt:encrypt (0:file wiped successfully) Command ran successfully ########### RUN 2 ################### /pgp/scripts->./error_checker.pl Something went wrong pgp:encrypt (3157:current local time 2016-09-22T17:15:32-04:00) /pgp/.pgp/pubring.pkr:open keyrings (1006:public keyring) /pgp/.pgp/secring.skr:open keyrings (1007:private keyring) 0x3279584E:encrypt (1030:key added to recipient list) 0x4B3DBEBE:encrypt (1050:key added as signer) /pgp/scripts/sample.txt:encrypt (3090:operation failed, file not found +) File is not found. Check the path again ########### RUN 3 ################### /pgp/scripts->./error_checker.pl Something went wrong pgp:encrypt (3157:current local time 2016-09-22T17:16:05-04:00) /pgp/.pgp/pubring.pkr:open keyrings (1006:public keyring) /pgp/.pgp/secring.skr:open keyrings (1007:private keyring) x3279584E:encrypt (3013:no keys found) Customer key is not found. Cannot encrypt

In reply to Re: Perl 5.10.1 - compare external program output with a list of known error codes by malokam
in thread Perl 5.10.1 - compare external program output with a list of known error codes by malokam

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.