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

Running Shell Script

Mac
2
7
461
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 Aug 2, 2023, 1:48 PM

    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?

    R 1 Reply Last reply Aug 2, 2023, 2:23 PM Reply Quote 0
    • R
      Russ @abaratz
      last edited by Aug 2, 2023, 2:23 PM

      @abaratz, that is strange.

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

      Russell VanderMey

      A 3 Replies Last reply Aug 2, 2023, 4:26 PM Reply Quote 0
      • A
        abaratz @Russ
        last edited by Aug 2, 2023, 4:26 PM

        @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 Aug 2, 2023, 4:33 PM

          @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 Aug 2, 2023, 5:25 PM

            @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.

            R 1 Reply Last reply Aug 2, 2023, 6:53 PM Reply Quote 0
            • R
              Russ @abaratz
              last edited by Aug 2, 2023, 6:53 PM

              @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 Aug 2, 2023, 9:09 PM Reply Quote 0
              • A
                abaratz @Russ
                last edited by Aug 2, 2023, 9:09 PM

                @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
                1 out of 7
                • First post
                  1/7
                  Last post