TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Run a shell script on a Mac

    Mac
    3
    3
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Matt PackwoodM
      Matt Packwood
      last edited by

      I am looking for examples of the syntax for the commands I can send, specifically how to execute a shell script...

      1 Reply Last reply Reply Quote 0
      • CheddarLifeFormC
        CheddarLifeForm
        last edited by

        Hi Matt, I'm struggling with this as well. I can't tell from the linux-like examples when one is supposed to escape special characters, like the forward slash.

        LED strip control from a Raspberry Pi | TRIGGERcmd Forum

        python3 \/root\/green.py
        

        Google assistant say the Raspberry Pi temperature | TRIGGERcmd Forum

        python3 /home/pi/temperature.py
        

        When I look at ~/.TRIGGERcmdData/debug.log it doesn't seem to record each attempt, i.e., I don't see entries when I execute a trigger from the web. I was sort of expecting something to be written to this log that corresponded with each entry seen under "View Runs" on the web interface.

        @Russ, could you clarify:

        • what environment variables are inherited by the agent running on the Mac, especially $PATH
        • where can I look to find the stdout/stderr result of executing a shell command
        • what exactly needs to be escaped, e.g., the inconsistent escaping of the forward slash as shown in the above examples
        RussR 1 Reply Last reply Reply Quote 0
        • RussR
          Russ @CheddarLifeForm
          last edited by Russ

          @CheddarLifeForm and @Matt-Packwood,

          You don't need to escape forward slashes yourself if you use the GUI editor. Just enter the paths like this: ~/script.sh (to refer to a script in your home directory). You only need to worry about escaping backslashes if you're editing your commands.json file directly.

          Here are some tips:
          Make your script executable with a command like this:
          chmod +x script.sh

          The ~ charactor refers to your home folder, so you can put scripts in folders in your home folder, and refer to them in the GUI editor like this: ~/scripts/myscript.sh

          Test your script from the bash prompt before testing in the GUI editor, and test using the green Play button in the GUI editor before testing using the Trigger button on the website, and test using that Trigger button before using something like Alexa.

          If you want to see the output from your commands, write it to a log file with >> like this:
          echo Hi >> ~/log.txt

          Russell VanderMey

          1 Reply Last reply Reply Quote 0
          • First post
            Last post