FAQ
I re-wrote the decryption routine to use system instead of Crypt::GPG,
and came across another puzzle:

my @gpg_command = ("/usr/bin/gpg --decrypt $encrypted >
$decrypted 2> /dev/null");
system(@gpg_command) == 0 or warn "system @gpg_command failed:
$!";

works. It decrypts my file successfully. But if I break up the arguments
like it says in the doco, like so:

my @gpg_command = ("/usr/bin/gpg", "--decrypt", $encrypted, ">",
$decrypted, "2> /dev/null");
system(@gpg_command) == 0 or warn "system @gpg_command failed:
$!";

it does not work. Instead I get a "usage" error.


Could someone please explain where I've gone wrong? I would like to use
Crypt::GPG instead of system, but I have to get this finished.
Thanks!

richf

Search Discussions

  • Wiggins d'Anconia at Jun 30, 2006 at 4:14 pm

    RICHARD FERNANDEZ wrote:
    I re-wrote the decryption routine to use system instead of Crypt::GPG,
    and came across another puzzle:

    my @gpg_command = ("/usr/bin/gpg --decrypt $encrypted >
    $decrypted 2> /dev/null");
    system(@gpg_command) == 0 or warn "system @gpg_command failed:
    $!";

    works. It decrypts my file successfully. But if I break up the arguments
    like it says in the doco, like so:

    my @gpg_command = ("/usr/bin/gpg", "--decrypt", $encrypted, ">",
    $decrypted, "2> /dev/null");
    system(@gpg_command) == 0 or warn "system @gpg_command failed:
    $!";

    it does not work. Instead I get a "usage" error.


    Could someone please explain where I've gone wrong? I would like to use
    Crypt::GPG instead of system, but I have to get this finished.
    Thanks!

    richf
    In my various attempts to get the gnupg related modules working on CPAN
    I came up with two options Crypt::OpenPGP which is in general slow
    because it attempts to do things in Perl, and GnuPG::Interface which
    worked almost perfectly but we were using it in a weird fork model kind
    of way, for doing a single encrypt/decrypt run at a time it worked
    brilliantly. Having said that, one caveat, my analysis was done in early
    2003.

    I would suggest giving GnuPG::Interface a go because it handled calling
    out to 'gpg' most "correctly". Meaning it uses the status-fd, logger-fd
    options properly which is the preferred way to call gpg in an automated
    fashion.

    Good luck,

    http://danconia.org
  • RICHARD FERNANDEZ at Jun 30, 2006 at 4:17 pm

    I would suggest giving GnuPG::Interface a go because it
    handled calling out to 'gpg' most "correctly". Meaning it
    uses the status-fd, logger-fd options properly which is the
    preferred way to call gpg in an automated fashion.

    Good luck,

    http://danconia.org
    Thank you! I will give it a shot.
  • Mumia W. at Jun 30, 2006 at 5:58 pm

    RICHARD FERNANDEZ wrote:
    [...]
    It decrypts my file successfully. But if I break up the arguments
    like it says in the doco, like so:

    my @gpg_command = ("/usr/bin/gpg", "--decrypt", $encrypted, ">",
    $decrypted, "2> /dev/null");
    AFAIK, you can't use "2> file" to do output redirection when you use the
    multiple-arguments form of 'system' because the shell isn't available.

    Use open() to redirect STDERR to /dev/null before you call system.

    Read "perldoc -f open."
    system(@gpg_command) == 0 or warn "system @gpg_command failed:
    $!";

    it does not work. Instead I get a "usage" error.
    [...]
    gpg doesn't know what to do with a parameter of "2> /dev/null."
    Could someone please explain where I've gone wrong? I would like to use
    Crypt::GPG instead of system, but I have to get this finished.
    Thanks!

    richf
    You're welcome.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedJun 30, '06 at 3:20p
activeJun 30, '06 at 5:58p
posts4
users3
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase