mirror of
https://github.com/amidaware/tacticalrmm.git
synced 2026-04-26 23:15:57 +03:00
[GH-ISSUE #1702] Bash scripts strange output on Linux agents #1065
Labels
No labels
In Process
bug
bug
dev-triage
documentation
duplicate
enhancement
fixed
good first issue
help wanted
integration
invalid
pull-request
question
requires agent update
security
ui tweak
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tacticalrmm#1065
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SpookOz on GitHub (Dec 11, 2023).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/1702
Server Info (please complete the following information):
Installation Method:
Agent Info (please complete the following information):
Describe the bug
It seems the (I believe) since a recent update, some of the Linux scripts are not acting as they should. The scripts are giving unexpected errors r output that do not occur if you run the same script locally. This does not happen with all scripts, just a couple. I have isolated some commands that don't work, but I can't find a pattern.
These examples are specific, but I believe they might point to a common problem in how the scripts are being interpreted in the agent.
To Reproduce
runuser -u apache -- wp plugin status "cloudflare" --path='/var/www/html'or
docker inspect --format='{{if eq .HostConfig.RestartPolicy.Name "unless-stopped"}}{{.Name}}{{end}}' $(docker ps -aq) | grep -v '^$' | sed 's#^/##'1A. Output if wp plugin status command is run locally:

1B. Output if wp plugin status command is run through TRMM script:

2A: Output if docker inspect command is run locally:

2B: Output if docker inspect command is run through TRMM script:

Expected behavior
Command 1 should output the status of the WordPress plugin. Instead it gives an error
Command 2 should show a list of only the names Docker containers with autostart set. Instead it lists every detail of the containers (as if the --format part of the command is being ignored.
Screenshots
Attached the output if run locally on the client as opposed to through a TRMM script.
Additional context
I'm fairly sure this used to work OK. Note, I have also created bash scripts with the commands in them and run them locally and they work fine. It's just if I run the script through TRMM that the issue occurs.
@SoarinFerret commented on GitHub (May 28, 2024):
I am running into this too - its from the docker inspect command. The
{{...}}}is getting registered as a variable for TacticalRMM, and gets substituted to nothing before being executed. Hence why the entiredocker inspectcommand is getting printed.An example proving it does not work correctly:
The only workaround I have found is to use variable expansion to get around the curly braces showing up. For example:
Yes, it looks terrible. But it works. I am too tired to try and find a better solution right now, so that's what I am going with - I'll reference this issue number in my script to remember why I did something so silly, and hopefully someone else will come up with something better by the next time I look at it.
@SpookOz commented on GitHub (May 29, 2024):
Of course! It's the double brackets! How did I not see that being the issue? Your solution - while not elegant - works well, and I would never have thought of it. Thanks so much!
@SpookOz commented on GitHub (May 29, 2024):
I think what threw me off is in some instances, it seems to work. for example:
docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"But I'm not sure why...
Edit: It looks like it is the "\t"
@wh1te909 commented on GitHub (May 29, 2024):
just pushed a fix for this. will be in next release or if you want to test it out now, run this