> I am making a call to gpg on the command line, a couple of
> the parameters that gpg will accept are file descriptor
> numbers that it then writes to, and I would like to capture
> that output and then read from it.
>
> I have successfully made it read directly from a file on the
> local file system like so:
>
> my $pass_fh = IO::File->new('/path/to/localfile');
> fcntl $pass_fh, F_SETFD, 0; # don't close over exec
> my $pass_fd = $pass_fh->fileno(); # get the file descriptor number
>
> and then calling gpg on the command line like so:
>
> gpg [other options here, etc.] --passphrase-fd $pass_fd [etc.]
>
> Which works very well. And I can successfully create a new
> file handle,
>
> my $logger_fh = IO::Handle->new();
>
> And then presumably could use the same methods as above, but
> the file handle has to be open to determine its number and
> then to pass the file descriptor to the command line. Which I
> determined is what fdopen is for, so now to my question(s)
> (finally, sorry about that) how do I determine what the FD
> (file descriptor number) should be that I pass to fdopen? Is
> this an arbitrary number (not 0,1,2), can I have the system
> suggest a number?  If the program were to choose the same
> number in different forks would it matter?  Is there a better
> more appropriate way of handling all of this?  (Besides using
> one of the GPG modules from CPAN, which I would absolutely
> love, but after spending a number of days checking them out,
> each one has one or more quirks which doesn't allow it to
> work in our app.)

I am not sure if this helps or if you already knew this, but the camel book
has section  on it in chapter 16, under the 'Passing File' Handles section.
also the fdopen manpages states that you obtain an existing FD from open,
fcntl..... So i assume the open method in IO::File is really the open2
system call.
Also are you loading the Fcntl module in the program so you get all of the
constants from cntl.h? 
Don't know if this helps you at all, but thought i would give throw it out
there.

Jim

ps.. I can send you the HTML section on this if you don't have it handy.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to