开发者

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".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜