Call python script in extcommands.xml
Hi
I have 0.65.0 running on an RPI and want to call a python script from within the extcommands.xml. The corrosponding section looks like this:
<command>
<name>Switch Relay</name>
<execute>sudo /var/lib/Repetier-Server/database/relay.py</execute>
</command>
I also added:
repetierserver ALL=NOPASSWD: /usr/bin/python
to /etc/sudoers.d, but when I finally tap on the button, nothing happens. Other commands work fine, just these python related won't work. When I execute /var/lib/Repetier-Server/database/relay.py from bash, it works fine.
I'm not very familiar with linux, so I have any clue whats going wrong here. Any hints?
Regards
Holger
I have 0.65.0 running on an RPI and want to call a python script from within the extcommands.xml. The corrosponding section looks like this:
<command>
<name>Switch Relay</name>
<execute>sudo /var/lib/Repetier-Server/database/relay.py</execute>
</command>
I also added:
repetierserver ALL=NOPASSWD: /usr/bin/python
to /etc/sudoers.d, but when I finally tap on the button, nothing happens. Other commands work fine, just these python related won't work. When I execute /var/lib/Repetier-Server/database/relay.py from bash, it works fine.
I'm not very familiar with linux, so I have any clue whats going wrong here. Any hints?
Regards
Holger
Comments
<command>
<name>Switch Relay</name>
<execute>/usr/bin/python /var/lib/Repetier-Server/database/relay.py</execute>
</command>
Nothing happens when tapping the button. Same call in bash works.
Starting manually brings up more detail:
Traceback (most recent call last):
File "/var/lib/Repetier-Server/database/relay.py", line 17, in <module>
GPIO.setup(RELAIS_1, GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!
So finally I NEEDED to sudo call python and the script from within extcommands.xml
<command>
<name>Switch Relay</name>
<execute>sudo /usr/bin/python /var/lib/Repetier-Server/database/relay.py</execute>
</command>
Thanks for your Help.
Hmmm, I'm wondering why I can execute the script from bash even without sudo, since I'm logged in as pi, not as root.