tags:

views:

23

answers:

1

Is it possible to use HTML form to start an executable in the server, and allow user to input further information into the same executable?

  1. from a web form, input executable name with one parameter missing.
  2. the executable starts, and post question for the missing parameter.
  3. user enter the value for the missing parameter, the information get passed to the executable.
  4. the executable continue its execution.

Thank you, Pan

A: 

Yes, but it's going to take some work! You may need to wrap the executable in something that is long running (IE, isn't stopped between page requests), start it on the first form submission, and then communicate with it via some form of IPC (say, local sockets on the server) from PHP on subsequent form submissions. The wrapper app should use something like popen() to start the executable you're trying to run as popen() will allow you to write to it's stdin... It will also be multi-threaded and read additional information from a socket that it then writes to the sub processes stdin.

dicroce
That is the issue I am facing. Seems like I need to set the stdout from PHP to the executable. I really like to see some examples for this.
Pan Chai
I'd wrap the executable in a "launcher" app... PHP is short lived... (It runs, returns something to the browser and then exits)... You need something that will keep running, even after the PHP script terminates... This sort of thing is trivial if you're experienced, but probably too hard for a novice as it's going to require some form of IPC from the PHP code to the "wrapper" server...
dicroce