in reply to How to Automate Response to Executable's Prompt?

Does this work on your platform?
system("echo|cmd ...")
That should put a newline on the program's standard input. If it doesn't work, then you want to use Expect.

Replies are listed 'Best First'.
Re^2: How to Automate Response to Executable's Prompt?
by socrtwo (Sexton) on Jun 11, 2012 at 12:26 UTC

    Tried it. Some of the sample corrupt docx work OK with your echo suggestion, but not the ones that usually prompt for answer about a split. Those are going into a race condition with the new echo command repeating ad infinitum:

    Could not find or open I:/socrtwo/Documents/Word Processor/docx/repairable/Ray_of_Hope_Chri +s_edits.dz01 Hit c (change path to where this split file is) s (skip this split) q (abort archive - quit) e (end this archive - no more splits) z (look for .zip split - the last split) or ENTER (try reading this split again):

    Will try the other suggestions in a minute.

Re^2: How to Automate Response to Executable's Prompt?
by socrtwo (Sexton) on Jun 11, 2012 at 18:57 UTC
    Expect or Expect::Simple look like they would work well. Unfortunately they require IO::Tty and apparently that won't install on Windows :-(. I need to work with Windows because I want to compile with pp to an exe...
      Unfortunately they require IO::Tty and apparently that won't install on Windows :-(.

      Hmmm....partially true. I'm not advocating that you go this route, but if you installed cygwin, in the cygwin environment with it's Perl it is possible to install the Expect modules. However, I'm not entirely sure that you could use pp to package your script into an executable that can be run on a Windows system that does not have the cygwin environment installed.

      Also, I want to point out one other thing to keep in mind before experimenting with cygwin. Supposedly it has an uninstaller. However, it's been my experience that if you want to uninstall cygwin, the only way to cleanly and completely uninstall it is to reinstall the Windows OS. Every time that I have ever tried to uninstall it, it has never completely uninstalled and some pieces of it are still hanging around. Perhaps they have improved the uninstall process over the past several years since I tried to go through the uninstall process.