Basically I have a server program that I'm trying to admin via perl. When you run the server, it takes over the console and provides it's own input/output, ignoring the shell. If that wasn't clear, perhaps this example might help. I invoke the server, it prints some status information then waits for input. I can type various commands to it, such as status and others, then it returns the information and awaits more input. It's basically an infinite read loop. My question was, how can I best interface with this program via perl?

By interface I mean read the data it prints, make some decisions and then "type in" more commands, read the data, repeat.

I of course tried some simple versions such as just `server` but of course the server program never finishes until you manually kill it, so the `server` statement doesn't return until the servers dead. I messed around a bith with a few other forms of open, but as far as I know I need both reading and writing, which plain old open doesn't do.

In reply to Best way to communicate with a shell like process? by BUU

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.