Results 1 to 6 of 6
Dear All,
I have a java application which send sms. So on console it works fine no problem. The problem comes when I start to run from the web browser ...
- 01-02-2011 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 64
php exec giving permission denied error
Dear All,
I have a java application which send sms. So on console it works fine no problem. The problem comes when I start to run from the web browser using the php exec method. Then I get error as "PortInUseException : java.lang.RuntimeException:
Error opening "/dev/ttyUSB0"
Permission denied".
I guess I must do some permission settings in linux any help please? Thank you.
- 01-02-2011 #2Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
Well it seems that the user of executing the php doesn't have the rights to open the USB Device.
On my system the user would be "www-data".
To get the user you simply ask your system:
ps -ef | grep apache
for example
However you should take a look what user / groups have the rights to open the device:
As far as i know it should be enough to add the user executing the php into the group.Code:ls -al /dev/ttyUSB0
A typical code to do this would be:
Code:usermod -a -G dialout www-data
- 01-02-2011 #3Just Joined!
- Join Date
- Jul 2010
- Posts
- 64
Dear Zom,
Ok first I ran thisThus the user here is known as apache.ps -ef | grep apache
apache 3025 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3027 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3029 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3030 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3032 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3033 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3034 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
apache 3035 2940 0 04:40 ? 00:00:00 /usr/sbin/httpd
root 3365 3260 0 04:52 pts/1 00:00:00 grep apache
Then I run thisThen I triedls -al /dev/ttyUSB0
crw-rw---- 1 root uucp 188, 0 Jan 1 04:44 /dev/ttyUSB0So what is my mistake ? Thank you.usermod -a -G dialout apache
usermod: unknown group dialout
- 01-02-2011 #4Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
usermod -a -G uucp apache
- 01-03-2011 #5Just Joined!
- Join Date
- Jul 2010
- Posts
- 64
Dear Zom,
Thank you it works now. Actually what is this command means ?
- 01-03-2011 #6Linux Newbie
- Join Date
- Dec 2009
- Posts
- 241
usermod
Is to change existing users
-a (add)
-G (Group)
uucp (Groupname)
apache (User that shall be modified)
ls -al /dev/ttyUSB0
Simply shows a line what user owns the device and what group has what rights to access:
crw-rw---- 1 root uucp 188, 0 Jan 1 04:44 /dev/ttyUSB0
Simply put:
root owns it
Members of Group uucp also have rw permission
anyone else has no permission
rw-rw----
The first 3 letters are for the owner, the second are the group and the last 3 is the rest.
You could also have solved it by allowing everyone to access the device (chmod).
Or you could have changed the owner or group with chown or chgrp.
But since it's a device I don't know if the system will remember such settings.
If you need more details you can access the manuals by writing:
man <command>
man usermod


Reply With Quote