Run script from Terminal Response - solved

the problem
I want to execute a script on the pi when a certain string appears in Terminal

** details**
specifically, I am embedding M118 "message" in the g-code
I want to detect "message" and run a script

** what I've done so far**
M118 part embedded in g-code
Terminal Response successfully "sees" the M118 reply and runs the command

what's wrong with that
it's simply sending the script back to the printer!

** sample**
Send: N1 M118 LEDs red103
Recv: LEDs red
Recv: ok
Send: ~/scripts/SetLeds 1 0 0
Changing monitoring state from "Starting" to "Printing"
Send: N2 M140 S60*81
Recv: echo:Unknown command: "~/scripts/SetLeds 1 0 0"

you can see my M118, and the expected echo
then you can see the script sent to the printer, instead of the pi!

Terminal Response setup
regex: LEDs red
Command: ~/scripts/SetLeds 1 0 0

environment
octoprint 1.4.0
octopi 0.17.0
Raspberry pi 3B
Creality Ender-3

so what did I do wrong?! :grinning:

See the Action Commands plugin: Action Commands
The string to output to the serial port should start with //action

@fieldOfView absolutely brilliant
works exactly as required
you, sir (or ma'am) are gentleman (or gentlewoman)!!