What I'm looking for is to execute an interactive script and ask user for input. The input format may vary from times to times the program being called, so I need the original prompt from the callee script and redirect stdin to the callee.
Currently I find that the passthru()
function in PHP just meets my need. However, is there an alternative to or ways to implement the passthru()
function?
UPDATE
An example (simpler as the real situation) to explain myself:
puts `sudo apt-get -y upgrade`
The sudo
command may ask user for password. For sudo
, the input format remains constant, I could use popen
for it. However what if the input format of the command being called is very complex and varies from times to times?