Don't ask to ask, just ask | |
PerlMonks |
Sending open file contents through an external programby pdac (Novice) |
on Aug 21, 2018 at 21:06 UTC ( [id://1220804]=perlquestion: print w/replies, xml ) | Need Help?? |
pdac has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I can't seem to find an answer anywhere to my problem. I hope there is one. This is what I am trying to do ... I have a perl script using CGI to collect the contents of an uploaded file from a web user. I have an open file handle that is serving the input. What I want to do is re-direct that input through an external program and read back its output. I've discovered how to use open to pipe to the standard input of an executed program OR to collect the standard output from one. I've also discovered socketpair() which I can see can be used with fork() to send/receive data to/from a parent and child process. But I cannot see how I can execute an external program and both send to its standard input and read from its standard output. The only solution I can think of is to use a temporary file (either for the input or the output of the external program). But I'd prefer not to go this route. Is there a better way? Can anyone help with this? BTW: I only need to keep compatiblity with UNIX
Back to
Seekers of Perl Wisdom
|
|