Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

digital1

macrumors 6502
Original poster
Jan 2, 2002
294
0
Wisconsin
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

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
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

macrumors 6502
Original poster
Jan 2, 2002
294
0
Wisconsin
I am trying to launch GUI programs as well as command Line programs. Thanks for the response! :)
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
digital1 said:
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 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

macrumors 6502
Original poster
Jan 2, 2002
294
0
Wisconsin
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.