This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

How to run complex Linux commands with core.local module?

Hi All,
Could you please let me know how to run complex Linux commands with core.local module?

I am running “st2 run core.local cmd=“echo Hello,Ramesh | awk -F’,’ ‘{print $2}’”” but it is not giving the expected output.
$ st2 run core.local cmd=“echo Hello,Ramesh | awk -F’,’ ‘{print $2}’”
2021-08-06 10:19:12,958 WARNING - Locale unknown with encoding unknown which is not UTF-8 is used. This means that some functionality which relies on outputting unicode characters won’t work. You are encouraged to use UTF-8 locale by setting LC_ALL environment variable to en_US.UTF-8 or similar.
.
id: 610d0ca1c220628e1bbe0216
action.ref: core.local
context.user: st2admin
parameters:
cmd: echo Hello,Ramesh | awk -F’,’ ‘{print }’
status: succeeded
start_timestamp: Fri, 06 Aug 2021 10:19:13 UTC
end_timestamp: Fri, 06 Aug 2021 10:19:13 UTC
result:
failed: false
return_code: 0
stderr: ‘’
stdout: Hello,Ramesh
succeeded: true

Thanks and Regards,
Ramesh

The output looks correct to me.

The command run from bash

Hello,Ramesh

Stackstorm result
stdout: Hello,Ramesh

I think the problem is the $ is a special character, so they wanted to run:

echo Hello,Ramesh | awk -F’,’ ‘{print $2}’

but if you look stackstorm ran:

echo Hello,Ramesh | awk -F’,’ ‘{print }’

You’ll need to escape the $ in the command - I can never remember if you will need one \ or two \, depends on when escapging is done.
But try running command:
echo Hello,Ramesh | awk -F’,’ ‘{print \$2 }’

Thank you @amanda11 and @Carlos for your quick response.