I have a program on my Linux server that asks the same series of questions each time it runs, and then provides a few lines of output. My goal is to automate input and output with php script.
The program is not intended to enter input on the command line. Instead, the program asks question 1 and waits for an answer from the keyboard, then the program asks question 2 and waits for an answer from the keyboard, etc.
I know how to capture output in an array by writing: $ out = array (); Exec ("my / path / program", $ from);
But how do I handle the input ? Suppose the program asks 3 questions and valid answers: left 120 n What is the easiest way to use php to pass this input to the program? Can I do it somehow on the exec line?
I am not php noob, but just never done this before. Alas, my googling goes in circles.
source share