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

    Running Shell Script

    Mac
    2
    7
    415
    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.
    • A
      abaratz
      last edited by

      I am seeing strange behavior when running a shell script. I am using foreground. When I run the command from the GUI editor, it doesn't immediately run. If I close the editor and re-open it, the command runs immediately upon reopening the editor. If I try to run the command from Alexa, it doesn't run at all. I have another command that uses pmset and that one runs fine. Any ideas what's happening?

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @abaratz
        last edited by

        @abaratz, that is strange.

        Can you share the script? It might give me a clue.

        Russell VanderMey

        A 3 Replies Last reply Reply Quote 0
        • A
          abaratz @Russ
          last edited by

          @Russ Here you go. Thank you.

          #!/bin/bash
          if [ "$1" == "open" ]
          then
          open -a "Slack"
          open -a "Microsoft Outlook"
          open -a "Safari"
          else
          shortcuts run "Quit All Applications"
          pmset sleepnow
          fi

          1 Reply Last reply Reply Quote 0
          • A
            abaratz @Russ
            last edited by

            @Russ Actually, I just removed the call to shortcuts and it ran fine. Should I be doing something differently with respect to running a shortcut in the script? Thank you.

            1 Reply Last reply Reply Quote 0
            • A
              abaratz @Russ
              last edited by

              @Russ Nevermind :). I just saw another post on running shortcuts. I wrapped the shortcuts call in my shell script inside of a call to AppleScript for running the shortcut and that worked. Sorry to bother you.

              RussR 1 Reply Last reply Reply Quote 0
              • RussR
                Russ @abaratz
                last edited by

                @abaratz, no problem. I'm glad you got it working.

                Would you mind sharing your final working script?

                Russell VanderMey

                A 1 Reply Last reply Reply Quote 0
                • A
                  abaratz @Russ
                  last edited by

                  @Russ Sure.

                  Here is the shell script:

                  #!/bin/bash
                  if [ "$1" == "start" ]
                  then
                  open -a "Slack"
                  open -a "Microsoft Outlook"
                  open -a "Safari"
                  else
                  osascript ~/Smarthome/Closeallapps.scpt
                  pmset sleepnow
                  fi

                  And here is the AppleScript for Closeallapps:

                  tell application "Shortcuts Events"
                  set theResult to run shortcut "Quit All Applications"
                  end tell

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