Monks

I am working on writing a Perl wrapper around the command line control utilities of a server. It is a log in "shell" essentially, so you start it with some basic information such as host and port and it provides you with a prompt, as so:

> {0}:

What I need to do now is send command in to this prompt sequentially, and potentially conditionally depending on logic in my wrapper. E.g. if I want to send the commands "start" and then "exit", thus if I typed it the prompt would look as follows:

> {0}: start

> {1}: exit

Is there any way in Perl I can achieve this, i.e. mimick manual input on stdin. If there is a way that uses only very core perl modules/core functionality that would be preferable as we only have a relatively basic installation of Perl and I cannot install new modules, but any help would be greatly appreciated.

Kind regards,

____________
Arun

In reply to Interacting With A Program Over Stdin/Exec by arunhorne

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.