naChoZ has asked for the wisdom of the Perl Monks concerning the following question:

This is my routine to try encrypting a file. When I run it with -wT it says "broken pipe". With just -w, the program just sits indefinitely. I tried running the script with < master.passwd out of desperation just to see if it might be waiting for the input to come from STDIN. Yields the same "broken pipe" error. I must disclaim again that I don't understand OO very well at all.
my $mpw_file = IO::File->new( "<$mpw" ) || die "\n\nUnable to open master.passwd file. $!\n"; my $gnupg = GnuPG::Interface->new(); $gnupg->options->hash_init( armor => 1, homedir => '/root/.g +nupg' ); $gnupg->options->push_recipients( 'foo@example.com' ); $gnupg->options->meta_interactive( 0 ); my @original_plaintext = <$mpw_file>; ##my $passphrase = "Three Little Pigs"; # We'll let the standard error of GnuPG pass through # to our own standard error, by not creating # a stderr-part of the $handles object. my ( $input, $output, $error, $status_fh ) = ( IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new() ); my $handles = GnuPG::Handles->new( stdin => $input, stdout => $output, stderr => $error, status => $status_fh ); # this sets up the communication # Note that the recipients were specified earlier # in the 'options' data member of the $gnupg object. my $pid = $gnupg->encrypt( handles => $handles ); # this passes in the plaintext print $input @original_plaintext; # this closes the communication channel, # indicating we are done close $input; close $mpw_file; my @ciphertext = <$output>; # reading the output my @status_info = <$status_fh>; # reading the status info my @error_output = <$error>; # reading the error print @ciphertext; print @status_info; print @error_output; waitpid $pid, 0; # clean up the finished GnuPG process # }}}

~~
naChoZ

Replies are listed 'Best First'.
Re: GnuPG::Interface encryption
by edoc (Chaplain) on Jun 02, 2003 at 23:26 UTC

    Maybe try adding a few print or warn statements so you can see how far it makes it through the script. Should at least help isolate the prolem area.

    cheers,

    J

      I tried this to isolate where it's breaking and it's definitely this line:

      print $input @original_plaintext;

      I don't really understand how the IO stuff works, I'm just trying to follow the docs. Any idea why this would bomb?

      ~~
      naChoZ

Re: GnuPG::Interface encryption
by naChoZ (Curate) on Jun 10, 2003 at 16:25 UTC
    Could anyone comment on this? I've been working on rectifying my lack of understanding of OO by reading perlman:perlboot and perlman:perltoot, but I'm not there enough to fix this particular problem I'm having.

    Thanx!

    ~~
    naChoZ