Hallo zusammen,
ich habe ein Problem mit PHP und dem Befehl "shell_exec".
Mein Ziel ist es, wo schon viele andere vor mir, eine Funksteckdose per Webinterface zu steuern.
Über die Kommandozeile klappt es prima, jedoch bekomme bekomme ich einfach keinen Rückgabewert (Output) zurück wenn ich es über PHP aufrufe.
Führe ich folgenden Befehl auf Kommandozeile aus bekomme ich einen Rückgabewert:
www-data@raspberrypi:~/home$ sudo /usr/local/sbin/send433 11111 11 1
sending systemCode[11111] unitCode[11] command[1]
Über PHP bekomme ich keinen Rückgabewert. Warum?
Hier dazu der PHP Code:
[code=php]
<?php
class Send433 {
private $systemCode = "";
private $unitCode = "";
function __construct($systemCode, $unitCode) {
$this->systemCode = $systemCode;
$this->unitCode = $unitCode;
}
private function sendSwitch($on) {
$command = $on == TRUE ? "1" : "0";
$cmd = "sudo /usr/local/sbin/send433 " . $this->systemCode . " " . $this->unitCode . " " . $command;
$output = shell_exec($cmd);
echo $cmd;
echo "\n";
echo $output;
}
function sendSwitchOn() {
$this->sendSwitch(TRUE);
}
function sendSwitchOff() {
$this->sendSwitch(FALSE);
}
}
$obj = new Send433("11111", "11");
$obj->sendSwitchOn();
?>
[/php]
Ich weis, das Thema wurde schon tausendfach diskutiert, aber ich komme nicht weiter.
Vielleicht weis von euch einer mehr dazu?
Vielen Dank.