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

Find a command line flag avoids having to type into the process. That "or die" you placed is unreachable code I think. It has to be outside of the system. 0 is success for command line programs usually. If true, its an exit code, and its an error exit code. On some OSes the exit code needs to be converted to be readable to typical C lib exit codes.

It is much more complicated to type into a process. Really really try and find a way around , look up what "-q" does and try it. If you must type into a command line program, you need IPC::Open3.
  • Comment on Re: How to Automate Response to Executable's Prompt?

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

    The problem with -q is zip -FF just blows on through and doesn't repair my sample file with the pseudo split archive structure. So I can't use quiet mode without sacrificing what I'm trying to do.

    OK so here is my IPC::Open3 statements so far:

    use IPC::Open3; my ($pid,$zipin, $zipout, $ziperr); $pid = open3 ($zipin, $zipout, $ziperr, system("cmd /c zip.exe -FF \"$ +mainfilepath\" --out \"$ziprepairedwordfilepath\"")); wait; $zipin = print "y\r\n";

    Any suggestion on how to construct wait or waitpid phrases? Right now whatever I do with wait or waitpid, printing 'y' into input, occurs after I enter 'y' by hand. $zipin never writes to the prompt.

    Update

    I'm looking of zip's C++ code in Visual Studio to see if I can compile my own version that always accepts that the archive is one disk.

      $pid = open3 ($zipin, $zipout, $ziperr, system("cmd /c zip.exe -FF \"$ +mainfilepath\" --out \"$ziprepairedwordfilepath\""));
      Thats broken. system read that. And read IPC::Open3. Your calling open3 wrong.
      $zipin = print "y\r\n";
      Thats broken. print read that. Perhaps another monk can comment if the wait() is correct.

      Update: As I reported in another part of this thread, I was able to get zip to compile without asking if my corrupt docx files were single archives or not.

      Also note -q and any other option does not work with -F or -FF. The only thing that works is --out probably also -O or --output-file. One of those three are a requirement whenever using -F or -FF.