mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-15 19:44:29 +05:00
doc: document passing parameters to gcode_shell_commands
This commit is contained in:
@@ -40,6 +40,34 @@ verbose: True
|
|||||||
Execute with:
|
Execute with:
|
||||||
`RUN_SHELL_COMMAND CMD=hello_world`
|
`RUN_SHELL_COMMAND CMD=hello_world`
|
||||||
|
|
||||||
|
### Passing parameters:
|
||||||
|
As of commit [f231fa9](https://github.com/th33xitus/kiauh/commit/f231fa9c69191f23277b4e3319f6b675bfa0ee42) it is also possible to pass optional parameters to a `gcode_shell_command`.
|
||||||
|
The following short example shows storing the extruder temperature into a variable, passing that value with a parameter to a `gcode_shell_command`, which then,
|
||||||
|
once the gcode_macro runs and the gcode_shell_command gets called, executes the `script.sh`. The script then echoes a message to the console (if `verbose: True`)
|
||||||
|
and writes the value of the parameter into a textfile called `test.txt` located in the home directory.
|
||||||
|
|
||||||
|
Content of the `gcode_shell_command` and the `gcode_macro`:
|
||||||
|
```
|
||||||
|
[gcode_shell_command print_to_file]
|
||||||
|
command: sh /home/pi/klipper_config/script.sh
|
||||||
|
timeout: 30.
|
||||||
|
verbose: True
|
||||||
|
|
||||||
|
[gcode_macro GET_TEMP]
|
||||||
|
gcode:
|
||||||
|
{% set temp = printer.extruder.temperature %}
|
||||||
|
{ action_respond_info("%s" % (temp)) }
|
||||||
|
RUN_SHELL_COMMAND CMD=print_to_file PARAMS={temp}
|
||||||
|
```
|
||||||
|
|
||||||
|
Content of `script.sh`:
|
||||||
|
```shell
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "temp is: $1"
|
||||||
|
echo "$1" >> "${HOME}/test.txt"
|
||||||
|
```
|
||||||
|
|
||||||
## Warning
|
## Warning
|
||||||
|
|
||||||
This extension may have a high potential for abuse if not used carefully! Also, depending on the command you execute, high system loads may occur and can cause system instabilities.
|
This extension may have a high potential for abuse if not used carefully! Also, depending on the command you execute, high system loads may occur and can cause system instabilities.
|
||||||
|
|||||||
Reference in New Issue
Block a user