Could anyone help me with this?
I've got decryption working fine, but now I'm trying to get encryption working
and having trouble. Here's my encryption routine.
I commented the @original_plaintext lines out to see if that would help, it
didn't. When I run it with -wT it says "broken pipe". With just -w, the
program just sits indefinitely. I tried running the script with " < filename"
out of desperation just to see if it might be waiting for the input to come
from STDIN. Yields the same "broken pipe" error. (FYI, I must disclaim that I
don't understand OO very well at all.)
I did isolate the problem to the problem to this line:
print $input $_ while <$mpw_file>;
But I'm not sure how to fix it. Any help would be appreciated. Thanx!
--
Andy
I've got decryption working fine, but now I'm trying to get encryption working
and having trouble. Here's my encryption routine.
Code:
# {{{ encrypt
my $mpw_file = IO::File->new( "<$mpw" ) ||
die "\n\nUnable to open file file. $!\n";
my $gnupg = GnuPG::Interface->new();
$gnupg->options->hash_init( armor => 1, homedir => '/root/.gnupg' );
$gnupg->options->push_recipients( 'root@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;
print $input $_ while <$mpw_file>;
# 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
# }}}
I commented the @original_plaintext lines out to see if that would help, it
didn't. When I run it with -wT it says "broken pipe". With just -w, the
program just sits indefinitely. I tried running the script with " < filename"
out of desperation just to see if it might be waiting for the input to come
from STDIN. Yields the same "broken pipe" error. (FYI, I must disclaim that I
don't understand OO very well at all.)
I did isolate the problem to the problem to this line:
print $input $_ while <$mpw_file>;
But I'm not sure how to fix it. Any help would be appreciated. Thanx!
--
Andy