Kwan Xian Posted January 13, 2019 Posted January 13, 2019 Hi,guys! when I build a pthon3 script with gui and GPIO contorl.I can run it when I use terminal with sudo command. But when I used "settings->session and startup" to config this script,It can't run when my device reboot (Orange Pi PC). I try to config command like: "echo 'password'|sudo -S python3 /home/kwan/OPi_PC/u_main.py" still the same. And then I tried to edit "/etc/rc.local" file and add: "echo 'password'|sudo -S python3 /home/kwan/OPi_PC/u_main.py &" still the same. The problem is when I run the other script without GPIO config and sudo command. It can run when device reboot. So,It's there anybody can tell me why & how to make it run with sudo. I really have no idea about it. Thx! tried: @reboot sudo python3 /home/kwan/OPI_PCPLUS/Linux_gate.py > /home/kwan/log.log Error: no display name and no $DISPLAY environment variable
Tido Posted January 13, 2019 Posted January 13, 2019 Hi Kwan Xian, I don't know which software you use, you might want to checkout this one: Within armbian you find following User-Supported options for GPIO and more: UserSpaceIO (libgpiod), pyGPIO accesses 'pins' directly through /dev/mem User Space IO is Python 3 and Java 8 bindings for user space GPIO, SPI, I2C, PWM and Serial interfaceshttps://forum.armbian.com/topic/6523-user-space-io-is-python-3-and-java-8-bindings-for-user-space-gpio-spi-i2c-pwm-and-serial-interfaces/ pyGPIO - A 'more general' python GPIO library based on pyA20https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library/
martinayotte Posted January 13, 2019 Posted January 13, 2019 7 hours ago, Kwan Xian said: So,It's there anybody can tell me why & how to make it run with sudo. I really have no idea about it. It can be workarounded also using setuid on python itself :
Kwan Xian Posted January 16, 2019 Author Posted January 16, 2019 On 1/14/2019 at 5:00 AM, martinayotte said: It can be workarounded also using setuid on python itself : Yes,You'r right. cp /usr/bin/python3 to /usr/bin/my-python and chmod 4775 /usr/bin/my-python. config "my-python {script-path}" for startup command. Now,my py script can run when device reboot. Thank You!
Recommended Posts