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?



permission










share|improve this question






















  • 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










  • 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










  • 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

















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?



permission










share|improve this question






















  • 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










  • 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










  • 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















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?



permission










share|improve this question













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?



permission







php linux apache shell raspberry-pi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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.log says)
    – 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 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










  • 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




















  • 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










  • 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










  • 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


















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



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values