I need to execute a series of commands on the OS from my PHP script. One of the commands, after being executed, prompts the user to enter a password, then enter password again (to verify the first input). How do I respond to these prompts from PHP?
Share
You can’t directly do that with
exec. You can do it by usingproc_openinstead; be sure to read the examples and comments to avoid some common pitfalls.Of course, possibly in your specific case maybe the problem can be circumverted by writing a shell script that feeds predetermined input into the spawned process’s STDIN instead; this could end up being simpler, if not as “pure”.