Running Shell Script
-
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?
-
@abaratz, that is strange.
Can you share the script? It might give me a clue.
-
@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 -
@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.
-
@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.
-
@abaratz, no problem. I'm glad you got it working.
Would you mind sharing your final working script?
-
@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
fiAnd here is the AppleScript for Closeallapps:
tell application "Shortcuts Events"
set theResult to run shortcut "Quit All Applications"
end tell
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