in reply to Re: OT: PGP encryption command to use in Perl
in thread OT: PGP encryption command to use in Perl

When I run using '-f' argument, the cursor is just stuck there and doesnt do any thing.

I tried the following and it worked but the description for 'w' scares me :(

$encrytion = `pgp -eaw +batchmode $file publickey.pgp`;

Description from Doc "This instructs PGP to create a ciphertext file “message.pgp”, and to destroy the plaintext file “message.txt”. Note that this option will not wipe out any fragments of plaintext that your word processor might have created on the disk while you were editing the message before running PGP. Most word processors create backup files, scratch files, or both. PGP overwrites the file 26 times."

Is it safe to use the above command or does it do something funky and I'm better off issuing a separate delete command for the original file?

Thank you for your help

Replies are listed 'Best First'.
Re^3: OT: PGP encryption command to use in Perl
by Corion (Patriarch) on Oct 13, 2015 at 07:54 UTC

    I couldn't test this and only showed you what I read from the manpage.

    Personally, I use a pipe through GPG like this:

    my $GPG_cmd = "/usr/bin/gpg --homedir . --keyring pubring.gpg --secret +-keyring secring.gpg --batch --trust-model always -z 7 --no-secmem-wa +rning --lock-never"; open my $gpg, qq(| $GPG_cmd --output "$OUTFILE") or die "Couldn't launch $GPG_cmd: $!"; print $gpg $mydata;
Re^3: OT: PGP encryption command to use in Perl
by soonix (Chancellor) on Oct 13, 2015 at 07:49 UTC
    Did you open it with
    open my $fh, "| pgp -f ..." or die ...
    or did you perhaps use the -f option with backticks?

    I don't know the specific version of pgp, Corion's seems to read from STDIN when -f is used, so this would just wait for your input from the keyboard (with backticks) instead of open "| ..." reading from the file handle.

    Update: Better style: Three argument form
    open my $fh, '|-', $cmd or die "failed to execute:\n\t$cmd\n$! +";
    References: qx and Quote Like Operators for backticks, Using open() for IPC for open