The return value is the exit status of the program as returned by the wait call. To get the actual exit value, shift right by eight (see below). See also exec. This is not what you want to use to capture the output from a command; for that you should use merely backticks or qx//, as described in `STRING` in perlop. Return value of -1 indicates a failure to start the program or an error of the wait(2) system call (inspect $! for the reason).
$dataFile = '/opt/ExportedPGPKeys/SampleData.txt'; $isEncrypted = system(qw'pgp -ea +batchmode', $dataFile, @sys); print " The output value is $isEncrypted \n";
You should note the most current Perl is 5.22, and I think 5.14 is already EOL'd. Not that old versions don't work just fine, and not that old versions aren't still bundled in modern OS's.
Your lack of my makes me concerned that you are learning old-style Perl. See for example Use strict warnings and diagnostics or die or Modern Perl.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In reply to Re^3: PGP encryption command not working thru Perl Backticks
by kennethk
in thread PGP encryption command not working thru Perl Backticks
by newperlmonkey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |