I have an executable that I need to call from my Perl script. It is pretty simple when run from the command line:

~$:/path/executable "Here is the script. Please choose option 1 or 2" 1 "Thank you. Please provide the input file name:" myInputFile.txt (script runs and output file appears in the directory) ~$:

I can't figure out how to supply the requested information from within the Perl script.

#I have tried my $program = "path-to-executable"; system($program); #The script hangs here until I manually enter the re +quested info at the command line system("1"); system("myInputFile.txt"); #Have also tried my $program = "path-to-executable"; my $i = `$program`; #Script hangs here and nothing appears on the comm +and line at all $i = `1`; $i = `myInputFile.txt`;

I have even tried adding sleep() commands but that does not fix the problem. Is there a way to let my script know it needs to keep talking to the executable?


In reply to Calling and interacting with external executable by verity

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.