I'm sorry, I was not able to install any of the existing GPG modules properly. I am using plain  open3 instead.

Note: If you are under mod_perl and go with  open3, remember to  untie STDIN, STDOUT, STDERR or you will get strange results.

This is the code I use for open3 (with some debugging commented out):

use IPC::Open3 (); # don't import open3 sub my_open3 { # cmd write read error my %opt = ( write => [], read => [], error => [], cmd => "ls", @_); my $stdin = tied *STDIN; my $stdout = tied *STDOUT; my $stderr = tied *STDERR; # temporarily turn off warnings # "untie attempted while 1 inner references still exist" { local $^W = 0; untie *STDIN if $stdin; untie *STDOUT if $stdout; untie *STDERR if $stderr; } my $pid = IPC::Open3::open3(*WTRFH, *RDRFH, *ERR, $opt{cmd}); unless ($pid) { print "can't fork: $!" if $DEBUG; return 0; } # local $SIG{PIPE} = sub { 1 }; # $pipe_error = 1 }; print WTRFH @{$opt{write}}; # || return 0; # die "can't write: $!"; close (WTRFH); # || return 0; #die "bad pipe: $! $?"; @{$opt{read}} = <RDRFH>; @{$opt{error}} = <ERR>; close (RDRFH); # || return 0; #die "bad pipe: $! $?"; close (WTRFH); # || return 0; #die "bad pipe: $! $?"; waitpid $pid, 0; tie *STDIN, ref $stdin, $stdin if $stdin; tie *STDOUT, ref $stdout, $stdout if $stdout; tie *STDERR, ref $stderr, $stderr if $stderr; return 1; # ok }

This is an example on how to use it:

my $gpg = "gpg ...options..."; my ($id, $pass, @data) = ('fglock','xxx',"data\n","data\n"); my (@result, @err); unshift @data, $pass . "\n"; $cmd = "$gpg --no-tty --local-user $id --passphrase-fd 0 --decrypt +"; my_open3( cmd => $cmd, write => \@data, read => \@result, error => \@err );

In reply to Re: GnuPG::Interface and fingerprint by fglock
in thread GnuPG::Interface and fingerprint by pawal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.