#!/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 permissions\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 in the filename or command\n"; } } else { print "$program_output3\n"; print "Command ran successfully\n"; } #### ########### 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-256) /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