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


In reply to Sending open file contents through an external program by pdac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.