in reply to Perl 5.10.1 - compare external program output with a list of known error codes

The problem is that the external program output from pgp operations usually contain multiple lines like below

pgp:encrypt (3157:current local time aa-bb-cc) /xxxx:open keyrings (1006:public keyring) /xxxx:open keyrings (1007:private keyring) yyyyy:encrypt (1030:key added to recipient list) yyyyy:encrypt (1050:key added as signer) sample.txt:encrypt (3090:operation failed, file not found)

Here, the last line is what matters to me and this is what needs to be compared to the error strings I mentioned in my original post. I am still unable to successfully catch the appropriate errors.

  • Comment on Re: Perl 5.10.1 - compare external program output with a list of known error codes
  • Download Code

Replies are listed 'Best First'.
Re^2: Perl 5.10.1 - compare external program output with a list of known error codes
by dasgar (Priest) on Sep 19, 2016 at 18:23 UTC

    Since you're using backticks, you're only capturing the STDOUT output of the PGP commands, but the error messages that you're wanting to check possible could be sent to STDERR instead. You could redirect STDERR to STDOUT by adding 2>&1 to the end of the PGP commands. Another alternative is to use Capture::Tiny, which will capture STDOUT, STDERR and exit code for external commands.

Re^2: Perl 5.10.1 - compare external program output with a list of known error codes
by stevieb (Canon) on Sep 19, 2016 at 19:25 UTC

    You did not specify that you were getting a whole screenful of output. My understanding was that you were receiving a single line like you had in your original post.

    For my example code to work, you have to extract *just* that piece and use it.