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

I am trying to call an interactive program from perl, which may or may not ask the user a question. How do I detect when the program has stopped and is awaiting input? Is there anyway to hide the input the user provides, such as passwords?

Replies are listed 'Best First'.
Re: Interacting with a program
by waswas-fng (Curate) on Dec 17, 2002 at 00:27 UTC
    Take a look at expect if you are doing this on unix, and be very careful how you do passwords like this -- many times there are better solutions than pushing passwords to interactive execs. Maybe if you go into a little more deatail on what you want to do we can provide you with some alternatives.

    -Waswas
(z) Re: Interacting with a program
by zigdon (Deacon) on Dec 17, 2002 at 14:01 UTC

    How do I detect when the program has stopped and is awaiting input?

    Usually programs should print out a prompt when they expect the user to respond - how else would the user know when and what kind of input is required?

    Is there anyway to hide the input the user provides, such as passwords?

    Yes, see Term::ReadKey. Edited from perlfaq8:

    How do I ask the user for a password?

    ... use Term::ReadKey; print "Enter your password: "; ReadMode('noecho'); $password = ReadLine(0);

    -- Dan