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

hello fellow monks, I tried this and it worked pretty good: my @args = ("Sandeep", "Appps"); my $prog = qq(echo $args[0]"\n"$args1 | /users/oracle/ap/perl/cloning/a.p l); open (JUNK,"$prog | "); thanks to one and all again!!

Replies are listed 'Best First'.
Re: Non-Interactive Inputs
by almut (Canon) on Jan 21, 2010 at 01:41 UTC

    In case the vendor script is reading from STDIN, you should be able to simply pipe your input to it (see IPC::Open3). Otherwise, if the script insists on reading from a tty, you'll have to make use of Expect.

      Thanks almut.
Re: Non-Interactive Inputs
by BrowserUk (Patriarch) on Jan 21, 2010 at 02:28 UTC
    I have a vendor supplied perl script.... I can not touch the script provided by vendor,

    I don't understand that? You don't have to touch the original, but you could just copy it into your own script, put your db query at the top, and then grab the data from the array or hash returned by the query instead of prompting for it.

    As long as you leave any copyright info intact, and are legally allowed to use the original script, it would be a very short-sighted vendor that would object.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Non-Interactive Inputs
by ikegami (Patriarch) on Jan 21, 2010 at 02:14 UTC

    If you need to capture the output of the script, IPC::Run3 might be the simplest solution.

    If you don't, open(my $to_chld, '|-', $prog, @args) is probably the simplest solution.