How to respond to prompts from a process spawned with `exec`?
I need to execute a series of commands on the OS from my PHP script. One of the commands, after being executed, prompts the use开发者_如何学Gor to enter a password, then enter password again (to verify the first input). How do I respond to these prompts from PHP?
You can't directly do that with exec
. You can do it by using proc_open
instead; 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".
精彩评论