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
Just add the arguments to the exec line.
exec("/path/to/programname $arg1 $arg2 $arg3");
... but don't forget to apply escapeshellarg() on every argument! Otherwise, you're vulnerable to injected malicious code.