PDA

View Full Version : PHP Help




digital1
Jun 4, 2006, 08:54 PM
I am trying to execute a system command to initiate a program. When I write a script such as :

<?php

system(kwrite);

?>

and I run it from the command line, it executes, but when I try to initiate that script from a post request from a web page(i.e. using a submit button to initiate a program) it does not execute. You guys have any advice? I am on Apache 2.

~Orlando



jeremy.king
Jun 5, 2006, 04:43 PM
Remember the web server runs as a different user. So make sure the command you are trying to run has execute permissions for that user.

Also, are you trying to launch a GUI'd application from a web page? Thats a whole different can of worms...

digital1
Jun 5, 2006, 04:49 PM
I am trying to launch GUI programs as well as command Line programs. Thanks for the response! :)

jeremy.king
Jun 5, 2006, 05:02 PM
I am trying to launch GUI programs as well as command Line programs. Thanks for the response! :)

I'll make the assumption that you realize you will be opening the program on the webserver and NOT your own machine. Unless, that is your machine IS the web server.

Care to share your goals of this exercise?

If you are set on launching GUI apps on the webserver, I would suggest writing a quick shell script and then call the shell script from your php script. Of course, the permissions thing still holds in this case, so you will need to grant the appropriate permissions to the script. Also, these apps probably won't even luanch unless that user (most likely called apache) is actually logged into the machine with Finder/WindowServer/etc running, which means you will probably need to perform some suexec lovin (http://httpd.apache.org/docs/1.3/suexec.html) or something similar


Now I am really curious, care to share your goals of this exercise?

Edit: Another thing to remember, if the command you are trying to issue isn't part of the system PATH, then you will require a full path to the command.

Care to share your goals of this exercise? ;)

digital1
Jun 5, 2006, 05:18 PM
the webserver runs locally. My goal is to do some usability guaging for some research I am doing. I have a backend database that keeps track of most of the apps that were launched by the system, and this will rank and show the highest results so you can launch from a single window. I do have the full path/command of the apps that I am working with as well.