I am trying to read in a command until it reaches a prompt where I am trying to get PHP to answer yes as the command I am using does not have an option to turn off batch prompts.

I have used popen to redirect the command but and am using a while wile loop with fgets to read in the results line by line but I can't work out how to check when the command stops to ask for the prompt.