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

I'm using Expect to automate running the build process for some modules that ask for configuration info. This works well, but the module Mail::Sender has a funky setup where it runs a separate script called Config.PL, and this doesn't seem to be caught by Expect. Does anyone know a way to make Expect handle processes that the initial command spawns?

Here's some sample code for what I'm doing:

my $command = Expect->spawn("perl Makefile.PL LIB=$dest_dir");

Replies are listed 'Best First'.
Re: Expect with command that spawns more processes
by esskar (Deacon) on Feb 27, 2004 at 22:14 UTC
    Does the "How can I expect on multiple spawned commands?" section in the Expect FAQ help you?
      I don't think so. That seems to apply to interacting with multiple commands. In this case, I ran a single command, but it spawned another process.
Re: Expect with command that spawns more processes
by tilly (Archbishop) on Feb 29, 2004 at 17:35 UTC
    I have no idea why the subprocess would not send its data to the same terminal that its parent is talking to. Is it at all possible that the subprocess is talking on STDERR when you Expect-ed STDOUT? You could try to redirect STDERR to STDOUT and see if it makes a difference.

    If that fails, you could try something random like spawning bash -l and then tell bash to run the Perl command. Maybe the subprocess will get confused enough to keep on talking to bash which is talking to Expect. Probably not. (If by some miracle that works and you don't want to hard-code the shell like that, you can perl -e 'exec {"$shell"} -sh' to get any login shell.)

    After that (maybe before trying random ideas) I would suggest reporting it as a possible bug and see if the current maintainer can suggest anything useful.

      I have no idea why the subprocess would not send its data to the same terminal that its parent is talking to.

      Thanks, your comments here caused me to go back and take a closer look at the generated Makefile, and it turned out that the problem came from the fact that it was the "make" command that generated this prompt, not the "perl Makefile.PL" command. I didn't realize this because I have it all scripted to run them automatically.

      So, the answer is that commands launched with Expect which spawn subprocesses are not a problem at all.