kantlivelong / OctoPrint-GCodeSystemCommands

Define G-Code commands that execute local system commands.
GNU Affero General Public License v3.0
37 stars 20 forks source link

How are optional parameters passed to the system command? #17

Closed justinmbrock closed 4 years ago

justinmbrock commented 4 years ago

For example, I have a binary system command /home/pi/foo that accepts command line arguments such as /home/pi/foo a b c. If I configured the gcode command OCTO3 to execute /home/pi/foo, would sending OCTO3 a b c work and pass the gcode parameters to the binary as command line arguments?

kantlivelong commented 4 years ago

You need create a wrapper script/application that reads the environment variables and does whatever is necessary.

justinmbrock commented 4 years ago

Thank you. I'm afraid I'm not that much of a programmer. What I have is a python script that needs root privileges to control a NeoPixel stick. Since any commands executed from within OctoPi inherit its non-root privileges I wrote a simple C++ binary to parse the command line arguments and execute the python script with PyRun_SimpleFile. I have no idea how to modify it to parse the environment variables. Is there somewhere you can point me with how it could work? I posted my code here, if you can take a look at it: https://github.com/justinmbrock/OctoPi-NeoPixel-Control

kantlivelong commented 4 years ago

You can post the question on https://community.octoprint.org

justinmbrock commented 4 years ago

I asked you because you wrote the plugin. "Create a wrapper to read the environment variables" doesn't help any. You have no documentation. What environment variables? What format are they given in? PyRun_SimpleFile only accepts wchar_t*, so I need to know if I need to convert it.

kantlivelong commented 4 years ago

This isn't support. The settings tab of the plugin will tell you what the environment variable names are.