tags:

views:

40

answers:

2

Hi, i start a linux console app from my php5 script, it starts ok but then termintates. I've tried using system(), shell_exec and tried starting as background process but to no avail it starts and then quits.

What i am trying to achieve is from a remote browser start a console app using a php5 script and then it should remain running (just as it would if i started it from a bash shell) , i then want to send commands (from a bash shell it would be keyboard strokes) to the console app from another set of php5 scripts. Hope its clear what i am trying to do.

If anyone could give some info on the best way about doing this, as i think i may have something fundamentally wrong. I have a Debian Lenny box running apache.The console app is just a simple program that prints to stdout and reads from stdin.

Thanks

A: 

How do you expect to send input to this app? Where is it listening for input?

It simply may only support interactive use, and exit as a result of that. Or, even simpler, it may terminate because it sees that is has no input (nothing piped in or nothing from some file) and since it's not connected to an interactive shell, it has nothing to do. There's no point in waiting for input from a user that doesn't have a way to interact w/ the application.

George Marian
Hi, i think what i'm looking for a is a way of writing to the stdin of another process( in this case the console app) from my php scriptThanks
tech74
A: 

On every request, PHP starts up, compiles your script and executes it. After execution, the script exists. When the script exits, all of the resources it was using, including file handles, database handles, and pipes to other programs are terminated.

You're going to need to find another way to keep your program open and have PHP communicate with it. Otherwise, every request to your script is going to open a new copy of the program, and then both will exit when the PHP script is complete.

Unfortunately without knowing what the program is, it will be hard to offer suggestions on how to go about doing this.

Charles