Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUN_SHELL_COMMAND not working with blank characters in parameter #425

Closed
Duffy77 opened this issue Jan 25, 2024 · 5 comments
Closed

RUN_SHELL_COMMAND not working with blank characters in parameter #425

Duffy77 opened this issue Jan 25, 2024 · 5 comments

Comments

@Duffy77
Copy link

Duffy77 commented Jan 25, 2024

Linux Distribution

OS: Raspbian GNU/Linux 11 (bullseye)
Distro: MainsailOS 1.3.2 (bullseye)

What happened

I installed kiauh and enabled the shell command feature.
Wrote my macro to pass a text variable to a shell script.
With a simple word it works, but when i use blanks, i got the following error message
image

What did you expect to happen

I would like to send use parameters with whitespaces

How to reproduce

My shell_command.cfg

[gcode_shell_command GitBackup]
command: sh /home/pi/printer_data/config/test.sh
timeout: 30.
verbose: True
[gcode_macro GitBackup]
gcode:
    {% set commitmsg = params.COMMITMSG %}
    { action_respond_info("%s" % (commitmsg)) }
    RUN_SHELL_COMMAND CMD=GitBackup PARAMS={commitmsg}

my script test.sh

#!/bin/bash
if [ -n "$1" ]; then
    varname="$1"
fi

# Ask the user for their name
echo Hello, who am I talking to?

echo It\'s nice to meet you $varname

When i place a parameter with whitespaces like this

image

i got the following error message
image

Additional information

No response

@Duffy77 Duffy77 added the Type: Bug Something isn't working as expected label Jan 25, 2024
@dw-0 dw-0 added not kiauh and removed Type: Bug Something isn't working as expected labels Jan 27, 2024
@dw-0
Copy link
Owner

dw-0 commented Jan 27, 2024

did you try and add quotation marks around my test?

@Duffy77
Copy link
Author

Duffy77 commented Jan 27, 2024

Hi,
When I put quotation marks around my test just like 'my test' then no error occurs direkt, but my ist passed as first parameter and I think test is the second .
But this is bad, because I would like a commit message to pass as first parameter

@dw-0
Copy link
Owner

dw-0 commented Jan 27, 2024

Another try would be to replace $1 with $@ in your bash script.

@Duffy77
Copy link
Author

Duffy77 commented Jan 27, 2024

This works :-) Thank you !

@Dalinaffeti
Copy link

Hi i am basically working around the same thing. I have a question after for example you have a g_code macro named: SET_PPR the param of ist named ppr. how can i use it in a g-code file. I mean how can i called and gived a value. Like example prr= 40.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants