executing a command via php on raspberry pi
up vote
0
down vote
favorite
I try to load this php file (bluetoothModul.php):
<?php
exec("echo '1' > /dev/rfcomm0");
?>
with this html file:
<html>
<head>
</head>
<body>
<a href="bluetoothModul.php"><img src="test.png"</a>
</body>
</html>
on my raspberry pi apache2 server but nothing happens.
If I execute the php file via command line: php bluetoothModul.php it is working correctly.
Maybe there is something wrong with the permissions?

php linux apache shell raspberry-pi
|
show 1 more comment
up vote
0
down vote
favorite
I try to load this php file (bluetoothModul.php):
<?php
exec("echo '1' > /dev/rfcomm0");
?>
with this html file:
<html>
<head>
</head>
<body>
<a href="bluetoothModul.php"><img src="test.png"</a>
</body>
</html>
on my raspberry pi apache2 server but nothing happens.
If I execute the php file via command line: php bluetoothModul.php it is working correctly.
Maybe there is something wrong with the permissions?

php linux apache shell raspberry-pi
Does the webserver running your PHP script, have access to echo things to/dev/rfcomm0? (Pro tip: Include what your/var/log/<webserver>/error.logsays)
– Torxed
Nov 10 at 19:30
how can I check that?
– Larsus
Nov 10 at 19:31
I just told you, check the error log. Or if that's empty, checkdmsgorjournalctl. Start by debugging before you ask questions, because we need this information and so do you. And maybe you'll figure something out while checking these basic things. Sorry for being blunt, but asking questions before checking logs is, well it's odd. But yes, this is most likely a permission problem, as you assumed yourself.
– Torxed
Nov 10 at 19:32
you're right sorry for that. In the log I get this: sh: 1: cannot create /dev/rfcomm0: Permission denied
– Larsus
Nov 10 at 19:35
There you go, now you dols -l /dev | grep rfcomm0and dops aux | grep <webserver>and check whether or not the user running the webserver have permissions on the object you're trying to write to. Most objects under/devis owned by root, tty, disk or audio/video. Rarely does anything in/devpermission bywww-data/http.
– Torxed
Nov 10 at 19:44
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I try to load this php file (bluetoothModul.php):
<?php
exec("echo '1' > /dev/rfcomm0");
?>
with this html file:
<html>
<head>
</head>
<body>
<a href="bluetoothModul.php"><img src="test.png"</a>
</body>
</html>
on my raspberry pi apache2 server but nothing happens.
If I execute the php file via command line: php bluetoothModul.php it is working correctly.
Maybe there is something wrong with the permissions?

php linux apache shell raspberry-pi
I try to load this php file (bluetoothModul.php):
<?php
exec("echo '1' > /dev/rfcomm0");
?>
with this html file:
<html>
<head>
</head>
<body>
<a href="bluetoothModul.php"><img src="test.png"</a>
</body>
</html>
on my raspberry pi apache2 server but nothing happens.
If I execute the php file via command line: php bluetoothModul.php it is working correctly.
Maybe there is something wrong with the permissions?

php linux apache shell raspberry-pi
php linux apache shell raspberry-pi
asked Nov 10 at 19:28
Larsus
106
106
Does the webserver running your PHP script, have access to echo things to/dev/rfcomm0? (Pro tip: Include what your/var/log/<webserver>/error.logsays)
– Torxed
Nov 10 at 19:30
how can I check that?
– Larsus
Nov 10 at 19:31
I just told you, check the error log. Or if that's empty, checkdmsgorjournalctl. Start by debugging before you ask questions, because we need this information and so do you. And maybe you'll figure something out while checking these basic things. Sorry for being blunt, but asking questions before checking logs is, well it's odd. But yes, this is most likely a permission problem, as you assumed yourself.
– Torxed
Nov 10 at 19:32
you're right sorry for that. In the log I get this: sh: 1: cannot create /dev/rfcomm0: Permission denied
– Larsus
Nov 10 at 19:35
There you go, now you dols -l /dev | grep rfcomm0and dops aux | grep <webserver>and check whether or not the user running the webserver have permissions on the object you're trying to write to. Most objects under/devis owned by root, tty, disk or audio/video. Rarely does anything in/devpermission bywww-data/http.
– Torxed
Nov 10 at 19:44
|
show 1 more comment
Does the webserver running your PHP script, have access to echo things to/dev/rfcomm0? (Pro tip: Include what your/var/log/<webserver>/error.logsays)
– Torxed
Nov 10 at 19:30
how can I check that?
– Larsus
Nov 10 at 19:31
I just told you, check the error log. Or if that's empty, checkdmsgorjournalctl. Start by debugging before you ask questions, because we need this information and so do you. And maybe you'll figure something out while checking these basic things. Sorry for being blunt, but asking questions before checking logs is, well it's odd. But yes, this is most likely a permission problem, as you assumed yourself.
– Torxed
Nov 10 at 19:32
you're right sorry for that. In the log I get this: sh: 1: cannot create /dev/rfcomm0: Permission denied
– Larsus
Nov 10 at 19:35
There you go, now you dols -l /dev | grep rfcomm0and dops aux | grep <webserver>and check whether or not the user running the webserver have permissions on the object you're trying to write to. Most objects under/devis owned by root, tty, disk or audio/video. Rarely does anything in/devpermission bywww-data/http.
– Torxed
Nov 10 at 19:44
Does the webserver running your PHP script, have access to echo things to
/dev/rfcomm0? (Pro tip: Include what your /var/log/<webserver>/error.log says)– Torxed
Nov 10 at 19:30
Does the webserver running your PHP script, have access to echo things to
/dev/rfcomm0? (Pro tip: Include what your /var/log/<webserver>/error.log says)– Torxed
Nov 10 at 19:30
how can I check that?
– Larsus
Nov 10 at 19:31
how can I check that?
– Larsus
Nov 10 at 19:31
I just told you, check the error log. Or if that's empty, check
dmsg or journalctl. Start by debugging before you ask questions, because we need this information and so do you. And maybe you'll figure something out while checking these basic things. Sorry for being blunt, but asking questions before checking logs is, well it's odd. But yes, this is most likely a permission problem, as you assumed yourself.– Torxed
Nov 10 at 19:32
I just told you, check the error log. Or if that's empty, check
dmsg or journalctl. Start by debugging before you ask questions, because we need this information and so do you. And maybe you'll figure something out while checking these basic things. Sorry for being blunt, but asking questions before checking logs is, well it's odd. But yes, this is most likely a permission problem, as you assumed yourself.– Torxed
Nov 10 at 19:32
you're right sorry for that. In the log I get this: sh: 1: cannot create /dev/rfcomm0: Permission denied
– Larsus
Nov 10 at 19:35
you're right sorry for that. In the log I get this: sh: 1: cannot create /dev/rfcomm0: Permission denied
– Larsus
Nov 10 at 19:35
There you go, now you do
ls -l /dev | grep rfcomm0 and do ps aux | grep <webserver> and check whether or not the user running the webserver have permissions on the object you're trying to write to. Most objects under /dev is owned by root, tty, disk or audio/video. Rarely does anything in /dev permission by www-data/http.– Torxed
Nov 10 at 19:44
There you go, now you do
ls -l /dev | grep rfcomm0 and do ps aux | grep <webserver> and check whether or not the user running the webserver have permissions on the object you're trying to write to. Most objects under /dev is owned by root, tty, disk or audio/video. Rarely does anything in /dev permission by www-data/http.– Torxed
Nov 10 at 19:44
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242641%2fexecuting-a-command-via-php-on-raspberry-pi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does the webserver running your PHP script, have access to echo things to
/dev/rfcomm0? (Pro tip: Include what your/var/log/<webserver>/error.logsays)– Torxed
Nov 10 at 19:30
how can I check that?
– Larsus
Nov 10 at 19:31
I just told you, check the error log. Or if that's empty, check
dmsgorjournalctl. Start by debugging before you ask questions, because we need this information and so do you. And maybe you'll figure something out while checking these basic things. Sorry for being blunt, but asking questions before checking logs is, well it's odd. But yes, this is most likely a permission problem, as you assumed yourself.– Torxed
Nov 10 at 19:32
you're right sorry for that. In the log I get this: sh: 1: cannot create /dev/rfcomm0: Permission denied
– Larsus
Nov 10 at 19:35
There you go, now you do
ls -l /dev | grep rfcomm0and dops aux | grep <webserver>and check whether or not the user running the webserver have permissions on the object you're trying to write to. Most objects under/devis owned by root, tty, disk or audio/video. Rarely does anything in/devpermission bywww-data/http.– Torxed
Nov 10 at 19:44