bash script not works with external commands

Hello everyone. 
when I run bash script from external commands nothing happens.

Script to turn on the printer
if [ ! -d /sys/class/gpio/gpio17 ]
  echo "17" > /sys/class/gpio/export
  sleep 1;
echo "out" > /sys/class/gpio/gpio17/direction
echo "1" > /sys/class/gpio/gpio17/value
When I run it from console it works.
In extcommands.xml 
I added /bin/bash to sudoers.d
# echo "repetierserver ALL=NOPASSWD: /bin/bash" > /etc/sudoers.d/repetierserver-bash
When I run external command nothing happens. Log says
Starting external command /var/lib/Repetier-Server/database/ with 0 parameters.
<execute>sudo /var/lib/Repetier-Server/database/</execute>
with same result.

Thank you for help.


  • Did your echo create the file? # is a comment so not sure you entered it or not.
    You are not starting /bin/bash but you start /var/lib/Repetier-Server/database/ so that should be executable.

    echo "repetierserver ALL=NOPASSWD: /var/lib/Repetier-Server/database/
    " > /etc/sudoers.d/repetierserver-turnon

    Then the version with sudo. But remember to restart server before testing or it will not use the sudo version.
  • pi@raspberrypi:~ $  sudo -u repetierserver /var/lib/Repetier-Server/database/
    /var/lib/Repetier-Server/database/ line 5: /sys/class/gpio/export: Permission denied
    /var/lib/Repetier-Server/database/ line 8: /sys/class/gpio/gpio17/direction: Permission denied
    /var/lib/Repetier-Server/database/ line 9: /sys/class/gpio/gpio17/value: Permission denied

    The cure is
    usermod -a -G gpio repetierserver

  • Ok, also a good solution. Even better because it does not require root permissions to execute the script.
Sign In or Register to comment.