Results 1 to 4 of 4
Hi,
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 ...
- 05-26-2010 #1Just Joined!
- Join Date
- May 2006
- Posts
- 13
apache run server side code via php
Hi,
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"
I only get "Current Temp:" on my page and an error in my /var/log/httpd/error_log:Code:<?php print("Current Temp:\n\n"); $thetemp = system('temper'); echo $thetemp; ?>
"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.
Thanks,
Pete.
- 05-26-2010 #2
It sounds like it is running the C program. Does the TemperCreate function require another file that Apache doesn't have permission to?
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
- 05-30-2010 #3Just Joined!
- Join Date
- May 2006
- Posts
- 13
update
The C code includes the following.
#include <usb.h>
and i think the library function that is casing the problem is:
usb_control_msg
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 ?
Thanks,
Pete.
- 05-30-2010 #4Just Joined!
- Join Date
- May 2006
- Posts
- 13
Solved
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:
note the addition of the "./"Code:$thetemp = system('./temper');
and all works great now

Pete.


Reply With Quote