You might try using IPC::Open3 or IPC::Open2 which are core perl modules and have the same gist as IPC::Run3.

If you only care about sending input to the shell script, which seems to be your intention, then you don't really need any of those modules. You can just use a piped open process. Piped processes have the disadvantage of only being able to read process output or send processes input, not both at once. Hence the need for the above modules. Sometimes that doesn't matter though...

#!/usr/bin/env perl use warnings; # you forgot use strict; # these two babies open my $abc, '|-', '/oracle/pieces/abc.sh' or die "open: $!"; print $abc "y\n" for 1 .. 3; close $abc or die "close: $!"; # You probably want to check to make sure abc did not fail, even if yo +u use # modules to start the process for you. if ($? != 0) { if ($? & 127) { printf STDERR "abc died with signal %d\n", $? & 12 +7 } else { printf STDERR "abc exited with error code %d\n", $? >> 8 } exit 1; }

This will print the output of abc to STDOUT. If you don't want this, you can add a pipe to devnull (>/dev/null) after the command.

edit: After posting this I remembered there is also the unix "yes" command, which echoes "y" forever. You pipe its output to the program of choice. For example on the shell: yes | /oracle/pieces/abc.sh. Perl might be unnecessary unless your needs are more sophisticated.

another edit: I had 0x127 in the code instead of 127. Not good.


In reply to Re^3: How to run a shell script from a Perl program? by juster
in thread How to run a shell script from a Perl program? by calsaint

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.