Code Comments
Programming Forum and web based access to our favorite programming groups.On Wed, 08 Jun 2005 09:24:43 +0100, darren@birkett.com (D. J. Birkett)
wrote:
>Thomas Bätzler wrote:
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) = ((),());
@answer = <OUT>;
print "out->@answer\n";
@err = <ERR>;
print "err->@err\n";
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Post Follow-up to this messagezentara wrote:
> On Wed, 08 Jun 2005 09:24:43 +0100, darren@birkett.com (D. J. Birkett)
> wrote:
>
>
> 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
Post Follow-up to this messageOn Thu, 09 Jun 2005 14:10:28 -0700, krahnj@telus.net (John W. Krahn) wrote: > >That makes no sense at all, and this being a beginners list I have to point it >out. Yes thanks for pointing it out. I should have just my(@answer,@err); I appreciate your efforts to keep us correct. :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.