extcommands.xml issues

I'm having some difficulty getting @execute commands working in Repetier-Server pro 0.80.3. I tried searching in the forums for solutions, but nobody seems to confirm if the suggested solutions work... 

I'm attempting to run a series of bash commands when a print finishes, errors out, etc. The idea is it will take a photo from the webcam, label it with the current time/date stamp, and then email it to me. When I run these commands via ssh, they work fine. However if I run them via the @execute command or the menu on Repetier-Server, nothing happens. I've tried setting up individual execute commands for each bash command, a single command for all of the commands, and even a bash script to run them with no success. The defined commands do show up in the menu on Repetier-Server, however only the example code from the manual actually works ("Reboot Server"). 

According to the server.log, Repetier-server imports all of the external commands and execute commands. When I execute either an external command or an execute command, it states "starting external command [....] with [n] parameters" (fill in the blank for each command line). I can post the log if requested.

Here is my extcommands.xml. It is located in /var/lib/Repetier-Server/database with repetierserver as owner, dialout as group, and 777 as the permissions. 
<config>
<command>
<name>Email Admin</name>
<execute>current_date_time = "`date +%Y%m%d%H%M%S`" ; wget http://127.0.0.1:8080/?action=snapshot -O $current_date_time.jpg ;  echo $current_date_time | mutt -a $current_date_time.jpg -s "Print Complete" -- email@address.com </execute>
<confirm>Send Email?</confirm>
</command>
<command>
<name>Reboot Server</name>
<execute>sudo /sbin/shutdown -r now</execute>
<confirm>Really reboot the server?</confirm>
</command>
<command>
<name>Test</name>
<execute>bash /home/pi/scripts/complete.sh</execute>
<confirm>Really?</confirm>
</command>
<execute name="aaron" allowParams="true">/usr/bin/wget http://127.0.0.1:8080/?action=snapshot -O test.jpg </execute>
<execute name="complete" allowParams="false">/usr/bin/sudo /usr/bin/bash /home/pi/scripts/complete.sh</execute>
<execute name="play" allowParams="true">/usr/bin/afplay</execute>
</config>

Here is the bash script ('complete.sh') I made, it located at the home directory. It is set to be executable. 

#!/bin/bash  
current_date_time="`date +%Y%m%d%H%M%S`"
wget http://127.0.0.1:8080/?action=snapshot -O $current_date_time.jpg
echo $current_date_time | mutt -a $current_date_time.jpg -s "Print Complete" -- email@address.com
echo test

I'm open to any suggestions to get this working. 




Comments

  • First always consider that commands on linux get executed a repetierserver user whcih has no shell. So you always need to sudo the commands and set sudo with no password for the command:

    All commands get executed with the user account and privileges the server daemon runs. So if you want to allow it to shutdown your computer, you need to add RepetierServer to the list of allowed users. To do this, open a shell and enter the following commands:

    
    # sudo -s
    # echo "repetierserver ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/repetierserver-shutdown
    
    Your complete command does not need the bash call - call script directly. wget needs absolute output path so you know where it
     stores image and folder must be world writable so it can write as repetieruser. Your script is also not
    using absoluet path!
Sign In or Register to comment.