[GH-ISSUE #71] macOS agent fails to execute shell scripts - missing shell interpreter invocation #43

Closed
opened 2026-03-02 02:12:55 +03:00 by kerem · 1 comment
Owner

Originally created by @probs-caffeinated on GitHub (Feb 7, 2026).
Original GitHub issue: https://github.com/amidaware/rmmagent/issues/71

It seems the TRMM agent (v 2.9.1) on macOS doesn't invoke shell scripts through a shell interpreter - it tries to execute them directly with execve(), which fails without a shebang.

macOS Agent calls execve() directly on .sh files instead of /bin/sh

Originally created by @probs-caffeinated on GitHub (Feb 7, 2026). Original GitHub issue: https://github.com/amidaware/rmmagent/issues/71 It seems the TRMM agent (v 2.9.1) on macOS doesn't invoke shell scripts through a shell interpreter - it tries to execute them directly with execve(), which fails without a shebang. macOS Agent calls execve() directly on .sh files instead of /bin/sh <script>, causing "exec format error" Below is agent log output for a script I created on TRMM server, with "Shell Type" set to "Shell", and "Supported Platforms" set to "macOS," then manually ran on my macOS endpoint running agent v 2.9.1. 7th line shows what I'm referring to. Running TRMM server v 1.3.1, and macOS agent v 2.9.1 ``` time="2026-02-07T14:02:52-08:00" level=debug msg="Checkrunner sleeping for 170" time="2026-02-07T14:03:17-08:00" level=debug msg="agent-agentinfo {l********************************E <my-username> wc-mba-m3 Darwin 26.2 arm64 25.2.0 darwin 24 1770241178 false arm64}" time="2026-02-07T14:03:27-08:00" level=debug msg="agent-hello {l********************************E 2.9.1}" time="2026-02-07T14:04:02-08:00" level=debug msg="agent-hello {l********************************E 2.9.1}" time="2026-02-07T14:04:37-08:00" level=debug msg="agent-hello {l********************************E 2.9.1}" time="2026-02-07T14:04:46-08:00" level=debug msg="agent-winsvc {l********************************E []}" time="2026-02-07T14:04:56-08:00" level=debug msg="RunScript(): /opt/tacticalagent/trmm10******90 []" time="2026-02-07T14:04:56-08:00" level=debug msg="{Status:{Cmd:/opt/tacticalagent/trmm10******90 PID:0 Complete:false Exit:-1 Error:fork/exec /opt/tacticalagent/trmm10******90: exec format error StartTs:1770501896839882000 StopTs:1770501896843979000 Runtime:0 Stdout:[] Stderr:[]} Stdout: Stderr:}\n" time="2026-02-07T14:04:56-08:00" level=debug msg="fork/exec /opt/tacticalagent/trmm10******90: exec format error\n" ```
kerem closed this issue 2026-03-02 02:12:55 +03:00
Author
Owner

@wh1te909 commented on GitHub (Feb 9, 2026):

This is the expected behavior. On linux and macos, the shebang is required for executable scripts. Without it, the agent has no way to determine which interpreter should be used, so execution will fail. The shebang path must exist on the endpoint for the script to run successfully.

The “Shell Type” setting in the UI is only used for syntax highlighting and does not affect how the script is executed. The agent intentionally invokes the file directly rather than wrapping it with /bin/sh, as this allows you to run scripts written in any language available on the endpoint, not just bash or sh.

<!-- gh-comment-id:3869829700 --> @wh1te909 commented on GitHub (Feb 9, 2026): This is the expected behavior. On linux and macos, the shebang is required for executable scripts. Without it, the agent has no way to determine which interpreter should be used, so execution will fail. The shebang path must exist on the endpoint for the script to run successfully. The “Shell Type” setting in the UI is only used for syntax highlighting and does not affect how the script is executed. The agent intentionally invokes the file directly rather than wrapping it with /bin/sh, as this allows you to run scripts written in any language available on the endpoint, not just bash or sh.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rmmagent#43
No description provided.