Problem with Perl Call

Jenkins, Graham K [IBM GSA] Graham.K.Jenkins@team.telstra.com
Sat Mar 9 01:59:02 2002


My example oversimplified things a bit. My program
is actually meant to feed printer files via email
to a remote printer (in parts if necessary). So it
really needs a separate program like you suggest to
prepend the passphrase.

I am actually doing it this way now - building and
invoking a separate perl program on the fly - and
it is working very well.  But it seems a bit kludgey.
So I thought "There has to be a better way .." 

Perhaps there isn't!

Thanks for your help.

G.

-----Original Message-----
From: Bart Martens
To: Jenkins, Graham K [IBM GSA]
Cc: 'gnupg-users@gnupg.org'
Sent: 3/8/02 11:34 PM
Subject: Re: Problem with Perl Call

On Fri, Mar 08, 2002 at 12:47:26PM +1100, Jenkins, Graham K [IBM GSA]
wrote:
> Guys, I have been trying to feed a passphrase into
> gpg 1.0.6 (on NetBSD, Solaris and Win32) platforms)
> using a variation of a script suggested in some of the
> pgp documentation.  Here's what I tried.  If somebody
> can tell me why it doesn't work, I'd be Real Pleased ..
> --
> #!/usr/local/bin/perl
> pipe(READER,WRITER);
> if (!fork) {
> 	close(WRITER);
> 	$^F=fileno(READER);
> 	$FilDes=fileno(READER);
> 	exec "gpg -as --passphrase-fd $FilDes </etc/passwd >/tmp/outZ"
or
> 	die "can't exec gpg\n";
> }
> close(READER);
> syswrite(WRITER, "secret1\n", 8);
> close(WRITER);
> wait
> --

You may want to try something like this:

 open FILE, "|gpg --batch --no-tty --passphrase-fd 0 --armor --symmetric
2>> $stderr > $stdout" or die "Cannot gpg";
 print FILE "passphrase\n";
 print FILE "text to be encrypted\n";
 close FILE;