Forum Moderators: coopster

Message Too Old, No Replies

The System() Function

         

Zorth

3:23 am on Mar 8, 2004 (gmt 0)

10+ Year Member



Hey all,

I'm trying to write a simple script which allows users to hit a link which opens a page. And by doing this, they restart a program that I am currently hosting.

I downloaded and installed pskill.exe which allows you to terminate a running proccess and using it in system(), but I can't seem to get system() to start a program.

Maybe using exec() would work?

Any help is appreciated.

Thanks :).

jatar_k

6:29 pm on Mar 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Zorth,

try exec or passthru depending on what type of output you need. From the sounds of it exec would be appropriate.

exec() executes the given command, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

We had some issues with memory_limit because it seems it takes into account the size of everything being exec'ed.

one thing to note about system as well

Note: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

Zorth

7:56 pm on Mar 8, 2004 (gmt 0)

10+ Year Member



I tried exec() last night as well. Both hang PHP because of the output.

I hear you can pipe it? Anyone mind telling me how to do this? I'll try passthru() as well and post what happened.

Thanks for the help.