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

    Running Shell Script

    Scheduled Pinned Locked Moved Mac
    7 Posts 2 Posters 1.8k Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Offline
                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 Offline
                  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

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post