i'm trying to script some backup software (BRU Server, if you must know), and the only way to use said software, unfortunately, is through an interactive shell, so I'm using IPC::Run:
# start the ipc $h = start \@cmd, \$in, \$out ; # send login info, keep reading until shell prompt $in = "$password\n" ; pump $h until $out =~ /BRU Server >/i ; # do what we need to do $in = "backup -some -params\n" ; pump $h until $out =~ /BRU Server >/i ; print "Output:\n$output"; # and, we're done here $in = "exit\n" ; pump $h while length $in; finish $h or die "oh crap: $?";
now, this will work, BUT in the case that one of these commands causes the program im talking to to suddenly die, it will keep pump()ing because it will never get the next prompt ("BRU Server >")...how can i tell it to wait for that prompt OR until the program dies?

and it bears mentioning that I can't really set a timeout on the "backup" command, since its an automated backup of variable size, so it could take anywhere from 30 seconds to i dont know how long.

i'd appreciate any help anyone can give me.

In reply to IPC::Run and start(); pump(); finish() by Anonymous Monk

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.