B
Bennett Haselton
If I have a program called foo that does something like:
Hello world. Should I continue? (y/n)
[user must type 'y' and hit Enter before continuing]
Thanks!
then how would I write a perl script that launches foo, waits until it
sees the line "Hello world. Should I continue? (y/n)", and
automatically enters the "y" response, all while printing to stdout
the output that foo is printing and the responses that the perl script
is entering? Actually, how can I do it without downloading and
installing any additional perl modules that don't come with the
standard perl distribution? (Even if there is a specialized class
that does it more elegantly, can I just do it with normal reads and
writes?)
I know this must be simple, and I tried to figure it out myself, but I
couldn't find any phrase to Google for that would give me the answer
(e.g. "perl automate entering input", etc.)
Is it just two lines of code? I know asking people to write code for
you is frowned upon, but in this case wouldn't it be faster than
typing a response in English sentences?
Hello world. Should I continue? (y/n)
[user must type 'y' and hit Enter before continuing]
Thanks!
then how would I write a perl script that launches foo, waits until it
sees the line "Hello world. Should I continue? (y/n)", and
automatically enters the "y" response, all while printing to stdout
the output that foo is printing and the responses that the perl script
is entering? Actually, how can I do it without downloading and
installing any additional perl modules that don't come with the
standard perl distribution? (Even if there is a specialized class
that does it more elegantly, can I just do it with normal reads and
writes?)
I know this must be simple, and I tried to figure it out myself, but I
couldn't find any phrase to Google for that would give me the answer
(e.g. "perl automate entering input", etc.)
Is it just two lines of code? I know asking people to write code for
you is frowned upon, but in this case wouldn't it be faster than
typing a response in English sentences?