PHP Help

Discussion in 'Mac Programming' started by digital1, Jun 4, 2006.

  1. macrumors 6502

    digital1

    Joined:
    Jan 2, 2002
    Location:
    Wisconsin
    #1
    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
     
  2. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #2
    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...
     
  3. thread starter macrumors 6502

    digital1

    Joined:
    Jan 2, 2002
    Location:
    Wisconsin
    #3
    I am trying to launch GUI programs as well as command Line programs. Thanks for the response! :)
     
  4. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #4
    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? ;)
     
  5. thread starter macrumors 6502

    digital1

    Joined:
    Jan 2, 2002
    Location:
    Wisconsin
    #5
    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.
     

Share This Page