http://www.perlmonks.org?node_id=951434

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

Hi all, I have one shell script which needs runtime input. I have run this script through another shell script as follows
./setup.sh << EOI a EOI

Now I want to run that setup.sh shell script through perl script instead of another shell script.

Replies are listed 'Best First'.
Re: Running shell script which needs runtime input through perl
by Eliya (Vicar) on Feb 02, 2012 at 15:01 UTC

    I think you want piped open:

    open my $fh, "| ./setup.sh" or die $!; # print $fh "$_\n" for qw(a b c ...);

    When you then say print $fh ..., the shell script gets the data on stdin, as it would from your current heredoc.

Re: Running shell script which needs runtime input through perl
by roboticus (Chancellor) on Feb 02, 2012 at 14:13 UTC

    snreddy_gopu:

    And your question is....?

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Running shell script which needs runtime input through perl
by toolic (Bishop) on Feb 02, 2012 at 14:35 UTC