Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    apache run server side code via php


    I have a usb temperature stick called TEMPer. I am using a c program I found which returns the current air temperature. What I would like to do is call this binary code from a webpage.

    I put the compiled code in /usr/bin and created the following file "index.php"

    print("Current Temp:\n\n");
    $thetemp = system('temper');
    echo $thetemp;
    I only get "Current Temp:" on my page and an error in my /var/log/httpd/error_log:

    "TemperCreate: Operation not permitted"

    Where TemperCreate is a function in the original C code. I guess this is a good thing as it is stopping apache from running server side code.

    So to my question. Is it possible to allow apache to run compiled C code ?

    Safe mode is turned off and I have tried making apache the owner of the binary, still no joy.

    Any suggestion would be great.



  2. #2
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Either at home or at work or down the pub
    It sounds like it is running the C program. Does the TemperCreate function require another file that Apache doesn't have permission to?
    Should you be sitting wondering,
    Which Batman is the best,
    There's only one true answer my friend,
    It's Adam Bloody West!

    The Fifth Continent

  3. #3


    The C code includes the following.

    #include <usb.h>

    and i think the library function that is casing the problem is:


    which has the following description:

    int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout);

    usb_control_msg performs a control request to the default control pipe on a device. The parameters mirror the types of the same name in the USB specification. Returns number of bytes written/read or < 0 on error.

    Is there a way of allowing the apache user to run this function, i.e. access to usb devices ?



  4. $spacer_open
  5. #4


    I just placed the binary executable in the same directory as my index.php file (instead of in /usr/bin) and I edited the system call to be:
    $thetemp = system('./temper');
    note the addition of the "./"

    and all works great now


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts