RepoJuice has asked for the wisdom of the Perl Monks concerning the following question:

I am a new Perl coder. I just started working at a company that designs, builds, and sells servers. I am developing a GUI for Perl legacy code that runs tests on the servers (via Linux command line) in our production facilities in Asia. I started from scratch using Perl/Tk and I am having an issue. In the GUI I input user data, then hit a button, and that executes a subroutine that uses CLI to start the test script. I use Scrolled to make a text window which displays the stdout of the test script as it runs. At one point the test stops and asks for user input in the text screen. I use a conditional to execute a DialogBox at this point. How do I pass the value collected in the DialogBox to the other script? Been struggling for awhile with this, please give me guidance informed travelers... PS~ I have no choice about using a GUI; this was a command directive to appeal to the lowest common denominator.

Replies are listed 'Best First'.
Re: Passing a Value
by graff (Chancellor) on Jun 19, 2015 at 02:00 UTC
    Ideally, the command-line tool(s) that you're trying to run should be able to operate without requiring user input after issuing the command line. The process should either get all the information it needs from the user via command line args, or else it should be able to get whatever it needs from a pipe or file redirection to its stdin (or environment variables, or a known config file, or...). Either way, you should be able to launch it and then just wait for it to finish, without further ado.

    If you absolutely must provide a GUI to a tool that absolute does not work that way, then I'd have to second the suggestion above about Expect and IPC::Open3. Yeah, eewwww. Either that or else fix/replace the CLI tool(s) you're using so that you don't have to write something really complicated that requires constant attention and piecemeal inputs from the GUI user.

Re: Passing a Value
by Anonymous Monk on Jun 18, 2015 at 23:24 UTC
Re: Passing a Value
by Anonymous Monk on Jun 18, 2015 at 22:38 UTC
Re: Passing a Value
by locked_user sundialsvc4 (Abbot) on Jun 19, 2015 at 11:41 UTC

    It would be helpful to us if you would post the specific snippet of your code (in proper code-tags) that is responsible for launching the child process and gathering the STDOUT/STDERR streams from it.   Superficially, that ought to be simple ... just intercept STDIN as well ... but things in Tk are not always so simple.   So, let us see just how you are now launching the child.   And, confirm how you are recognizing that it has produced an output that is a prompt.