EvanK has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a web-based interface script (to sit between the user and some database tools), and at several points I'll be having to use interprocess communication. I'm trying to decide what is both the most optimized AND the most secure way to do this. I was originally thinking IPC::Open2, but I'm considering IPC::Run.

Here's what I have:

index.pl <-- interface, sits between the user and the different tools

auth.pl <-- one of the many tools, a script that takes user info (ex: a username & password) and authenticates it against database information

now, i want index.pl to start an instance of auth.pl and pipe the user information to it (not pass it as cmdline arguments), then read the output of auth.pl after it exits.

would IPC::Open2 or IPC::Run be the best solutions for this? or is ther something better suited? (i like the fact that IPC::Run has built-in timeouts). i appreciate advice anyone can give me.

__________
Give a man a match and he'll be warm for an hour. Set him on fire and he'll be warm for the rest of his life.

Replies are listed 'Best First'.
Re: IPC::Open2 or IPC::Run or a better way?
by eXile (Priest) on Aug 24, 2005 at 03:31 UTC
    Depending on the complexity of what you want to my choices (purely based on having some experience with these modules) would be:

    IPC::Open2 (simplest)

    Expect (little more complex, little more control)

    POE (complexer, but offers more bells and whistles) From your description I'd probably go for the simplest one.

Re: IPC::Open2 or IPC::Run or a better way?
by nothingmuch (Priest) on Aug 24, 2005 at 08:08 UTC
    I'd use IPC::Run... It's consistent, relatively easy to use, and very flexible.

    I especially like using callbacks for output collection and input generation.

    As for IPC::Open2 and IPC::Open3 and all those - i don't like them because they're inconsistent with each other, and have no way to do easy things like "the input is this string", or "slurp the output into this var" and so on.

    Furthermore, IPC::Run has nice tools to abstract select loops (see pump), and in that way makes deadlock avoidance easier.

    -nuffin
    zz zZ Z Z #!perl
Re: IPC::Open2 or IPC::Run or a better way?
by pg (Canon) on Aug 24, 2005 at 04:16 UTC

    IPC::Run does give you more control, but it also requires (much) more coding to really get the benefits. In your case, you don't seem to need more than what IPC::Open2 can provide.