I have a program on my linux server that asks the same series of questions each time it executes and then provides several lines of output. My goal is to automate the input
First up, just to let you know that you're trying to reinvent the wheel. What you're really looking for is expect(1), which is a command-line utility intended to do exactly what you want without involving PHP.
However, if you really want to write your own PHP code you need to use proc_open. Here are some good code examples on reading from STDOUT and writing to STDIN of the child process using proc_open
:
Finally, there is also an Expect PECL module for PHP.
Hope this helps.