Problem with Perl Call

Bart Martens bart.martens@advalvas.be
Fri Mar 8 13:23:02 2002


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;