Hi,

I'm trying to use open3 to control input to an external program (in this case gpg). I would use Expect, but I need to use packages that are installed as standard with perl as this script will be running on many platforms. I simply want to enter interactive mode of gpg, pass it 3 commands, then exit back to my script. The following code runs gpg in interactive mode, but none of the commands get passed to it and it just sits there till I exit manually, then it comes back to my script.



use IPC::Open3;

local(*HIS_IN, *HIS_OUT, *HIS_ERR);

$childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, 'gpg --edit root');

print HIS_IN "trust\n5\yes\n";
close (HIS_IN);
my @outlines = <HIS_OUT>;
my @errlines = <HIS_ERR>;
close HIS_OUT;
close HIS_ERR;
waitpid($childpid, 0);
if ($?) {
        print "Child exited with status of $?\n";
}

If I remove the "close (HIS_IN)" statement


Is it possible to do what I want with open3, and how?

Thanks
Darren

--
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