Shell script command executed with action script fails

Hi All,

Need some help here, trying to execute a command (works manually on server) via BigFix Action script and it fails.
Command is
systemctl status wazuh-agent.service | grep active | awk -F’ ’ ‘{print $2}’ > /tmp/wazuh_status.txt

Used the conversion utility and running it as below

//Shell to Action Script Conversion Utility
delete __appendfile

appendfile #!/bin/sh
appendfile systemctl status wazuh-agent.service | grep active | awk -F’ ’ ‘{print $2}’ > /tmp/wazuh_status.txt

//modify appendfile to allow execution
wait chmod 555 "{(client folder of current site as string) & “/__appendfile”}

//execute shell script as written
wait “{(client folder of current site as string) & “/__appendfile”}”

However I did try to run choosing the option ‘sh’ as below
#!/bin/sh
rm -f /tmp/wazuh_status.txt
systemctl status wazuh-agent.service | grep active | awk -F’ ’ ‘{print $2}’ > /tmp/wazuh_status.txt
It worked.
Not sure what was not correct in BigFix action script to execute the shell command.

Please suggest!! Ty

See Tip: Escaping curly brackets for substitutions in ActionScript

awk -F’ ’ ‘{print $2}’ 

…is interpreted as a relevance substitution. Try

awk -F’ ’ ‘{{print $2}’
1 Like

Thanks a Lot Jason, Understood.

1 Like