Skip to content

Commit

Permalink
gcode_shell_command: make RUN_SHELL_COMMAND accept optional parameters
Browse files Browse the repository at this point in the history
Thanks @lixxbox for that code
  • Loading branch information
dw-0 authored Oct 17, 2021
1 parent 9b6925e commit f231fa9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion resources/gcode_shell_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def _process_output(self, eventime):

cmd_RUN_SHELL_COMMAND_help = "Run a linux shell command"
def cmd_RUN_SHELL_COMMAND(self, params):
gcode_params = params.get('PARAMS','')
gcode_params = shlex.split(gcode_params)
reactor = self.printer.get_reactor()
try:
proc = subprocess.Popen(
self.command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.command + gcode_params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except Exception:
logging.exception(
"shell_command: Command {%s} failed" % (self.name))
Expand Down

3 comments on commit f231fa9

@jktightwad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the proper format for passing multiple parameters, for example:
{temp}
{speed}
{flow}

@re3Dev
Copy link

@re3Dev re3Dev commented on f231fa9 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the proper format for passing multiple parameters, for example: {temp} {speed} {flow}

I am also interested in the correct syntax for this.

@ArsicN
Copy link

@ArsicN ArsicN commented on f231fa9 Mar 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it's an old commit, but I couldn't seem to find any reference or example on how to pass multiple parameters to a command. So I tested it myself and found a solution. Leaving it here just in case anyone else wants the same and runs into this:
PARAM="{argN1} {argN2} {argN}" if using klippper variables. In my case it was something like: RUN_SHELL_COMMAND cmd=graph_raw_values PARAMS="-a {accel} -c {cruiseratio} -x {axis}" for a custom script I was using. Cheers

Please sign in to comment.