How to skip 'Cancel' 'Continue' when running shell script with automator? I'm trying to run pmset sleepnow linked to a keyboard shortcut with automator. When I use the shortcut, it's giving me a 'Cancel' or 'Continue' prompt. Anyway to skip this so the script just runs when I press the key combo?
I'm not able to replicate your prompt issue if I code the sleepnow in a do shell.


Launch Automator
Go to File &gt; New
Select Service and click Choose
Select "No input" in drop-down list
Select in drop-down list "Any application"
Select "Run AppleScript" and double-click or drag and drop
Replace the script with a do shell
Save the service
Add service in keyboard




The code:

try
    display notification "Attempting sleep"
    delay 2
    set result to do shell script "pmset sleepnow"
on error result
    display dialog result
end try


The service with shortcut:



System specs:

macOS Sierra Version 10.12.6 on Macbook Pro