Hallo,
ich hoffe ich bin hier im Richtigen Forum...
Zu meinem Problem: Ich habe mir eine Website mit Apache erstellt und einige Befehle eingebaut, welche Python-Scripte ausführen, allerdings werden erst einmal alle Befehle beim Laden der Seite ausgeführt. Wie kann ich das vermeiden, dass beim neuladen der Website nicht einmal alle Befehle ausgeführt werden.
zur Hilfe hier mein Quelltext:
PHP
<html>
<body bgcolor="#808080">
<?PHP
if(isset($_GET['Befehl'])) {
//EINSCHALTEN
if($_GET['Befehl'] === 'ledein') {
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 4 0")); //Befehl an die Shell senden um GPIO 23 einzuschalten
}
//AUSSCHALTEN
//LED1
elseif($_GET['Befehl'] === 'ledaus') {
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 4 1"));
}elseif($_GET['Befehl'] === 'bildmachen'){
$val = trim(@shell_exec("/opt/vc/bin/raspistill -q 100 -br 50 -ex auto -co 20 -sa 20 -mm average -sh 10 -w 380 -h 200 -n -o /var/www/image.jpg"));
}}
?>
<table border=0>
<tr>
<td>a1</td>
<td style="text-align:center">a2<a href="<?php echo shell_exec("sudo /home/pi/motorl.py")?>"><img style="3px" src="poben.jpg" /></a></td>
<td>a3</td>
</tr>
<tr>
<td style="text-align:center">b1<a href="<?php echo shell_exec("sudo /home/pi/motorl.py")?>"><img style="3px" src="plinks.jpg" /></a></td>
<td>b2<a href="<?php print($_SERVER['PHP_SELF']); ?>?Befehl=bildmachen"><img src="image.jpg" width="800" height="500"/></a></td>
<td style="text-align:center">b3<a href="<?php echo shell_exec("sudo /home/pi/motorl.py")?>"><img style="3px" src="prechts.jpg" /></a></td>
</tr>
<tr>
<td>c1</td>
<td style="text-align:center">c2<a href="<?php echo shell_exec("sudo /home/pi/motorl.py")?>"><img style="3px" src="punten.jpg" /></a></td>
<td>c3</td>
</tr>
<tr>
<td>d1</td>
<td style="text-align:center">d2<a href="<?php print($_SERVER['PHP_SELF']); ?>?Befehl=ledein"><img src="Ein.jpg"/></a>
<a href="<?php print($_SERVER['PHP_SELF']); ?>?Befehl=ledaus"><img src="Aus.jpg"/></a></td>
<td>d3</td>
</tr>
</table>
</body>
</html>
Alles anzeigen