저는 나무 딸기 파이가있는 Noob입니다. 모든 설정을 가지고 있고 브라우저를 통해 shell_exec
을 사용하여 파일을 실행하려고합니다. 여기 /dev/mem에 액세스 할 수 없습니다. Raspberry Pi에서 루트로 실행하십시오.
#! /usr/bin/python
import time
import RPi.GPIO as GPIO
PIN_17 = 17 # Define LED colour and their GPIO pin
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN_17, GPIO.OUT) # Setup GPIO pin
GPIO.output(PIN_17, True) #Turn on
time.sleep (1) #Wait
GPIO.output(PIN_17, False) #Turn off
GPIO.cleanup() #Useful to clear the board
나는라는 디렉토리 /home/pi/
에있는 파일이 trigger_pin.py
나는 아래의 PHP의 명령을 사용하여 브라우저를 통해 파일을 실행하려고 remote.php
:
<?php
$output = shell_exec("cd /home/pi/ && ./trigger_pin.py 2>&1"); //run command
echo "$output"; //output from command
?>
내가 얻고 출력은 다음과 같습니다
Traceback (most recent call last): File "./trigger_pin.py", line 9, in GPIO.setup(PIN_17, GPIO.OUT) # Setup GPIO pin RuntimeError: No access to /dev/mem. Try running as root!
영업 이익은 오히려 웹 응용 프로그램에서 호출 스크립트에서 exec'ing, 명령 줄에서이 실행되고 있지 않습니다. –