zentara wrote:
On Wed, 08 Jun 2005 09:24:43 +0100, [EMAIL PROTECTED] (D. J. Birkett)
wrote:

Thomas Bätzler wrote:

D. J. Birkett <[EMAIL PROTECTED]> asked:

OK I've tried altering my code as you suggested, replacing the regexes with ones that would work. gpg still just sits there as soon as it has entered it's intereactive mode, and perl doesn't seem to be passing any commands to it at all.

Any other ideas?

Well I'm a "zen hacker" and like a million monkeys, I sometimes get
lucky.

You may need the latest gpg 1.4.1 for this to work, but I may be wrong.
Anyways, there is a new option for sending commands to gpg, and you
can do what you want with the following script. Try it, it works.

First set the string to "trust\n1\ny\n" then to "trust\n\5\y\n". Its funny how 'your' first attempt wasn't so bad after all.

The secret is the --no-tty option in conjunction with --command-fd Search the gpg source distribution for details about these commands.

It certainly makes sense now that I see it.

#!/usr/bin/perl
use warnings;
use strict;
use IPC::Open3;

local $SIG{CHLD} = 'IGNORE';
local $SIG{PIPE} = 'IGNORE';

my $childpid = open3(\*IN, \*OUT, \*ERR,
   'gpg  --no-greeting --no-tty  --command-fd 0 --status-fd 1 --edit
zentara');

print IN "trust\n5\ny\n";
close IN;

my(@answer,@err) = ((),());

That makes no sense at all, and this being a beginners list I have to point it out.

perldoc perldata
[snip]
       You can actually put an array or hash anywhere in the list, but the
       first one in the list will soak up all the values, and anything after
       it will become undefined.


So the array @answer will receive everything from the assignment. But the assignment is superfluous because my() creates empty arrays.


 @answer = <OUT>;
 print "out->@answer\n";

 @err = <ERR>;
 print "err->@err\n";

A "more correct" idiom is:

my @answer = <OUT>;
print "out->@answer\n";

my @err = <ERR>;
print "err->@err\n";

__END__



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to