2

I would like to automate my Mac installation flow for services. The following is my script:

#!/bin/sh
rm -rf ./tempWorkflows
mkdir tempWorkflows
for filename in ./*.workflow; do
    cp -R "$filename" ./tempWorkflows/"$filename"
done
for filename in ./tempWorkflows/*.workflow; do
    open $filename
done
rm -rf ./tempWorkflows

It basically copy all my *.workflow and open it. However, for open $filename, it prompts and asking for a confirmation:

popup

Is there a way to add --no-prompt or similar flag for the open command?

EDIT:

I am using El Capitan 10.11.3

  • It's doable however depending on the version of OS X you're running will have bearing on the implementation of the method. – user3439894 Feb 11 '16 at 4:18
  • Updated Mac OS info. I am using 10.11.3, thanks – EES Feb 11 '16 at 4:21
  • This can be done using either AppleScript or Automator creating an application bundle as this will be necessary to allow the App to control your computer by clicking the Install and Done buttons on the Service Installer dialog box. Doing an Automator app probably would be easiest, using a Run Shell Script Action and a couple lines of AppleScript code using osascript by adding a few lines after the open $filename line. If your interested I'll create an answer for it however I do not have OS X 10.11 although this does work in OS X 10.10 it should also work in OS X 10.11. Let me know. – user3439894 Feb 11 '16 at 4:44
  • BTW You should have quotes around $filename in open "$filename" in case any of your Automator Services .workflow files have spaces in the names. – user3439894 Feb 11 '16 at 13:17
2

If Automator is closed then open Automator and select Application under Choose a type for your document, then click the Choose button. If it's already open the choose File > New and select Application under Choose a type for your document.

Add a Run Shell Script Action to it.

Copy and paste the shell code you presently have into the Run Shell Script Action.

Add the following lines of code after: open $filename

sleep 1
osascript -e 'tell application "System Events" to click button "Install" of window "Service Installer" of process "Automator"'
sleep 1
osascript -e 'tell application "System Events" to click button "Done" of window "Service Installer" of process "Automator"'

Note: You should also add an appropriate cd line above the rm -rf ./tempWorkflows line you presently have in your code, e.g. cd /some/directory/path where it's the pathname of the location your .workflow files are located for processing by your script.

Save the Automator Application as Install Automator Service. Install Automator Service Next:

Open System Preferences > Security & Privacy > Accessibility > Privacy

Click the Lock icon to make changes and type in your password, then click the Unlock button.

User the [+] to add the Install Automator Service or drag and drop the application bundle into the window. Accessibility This will now allow the Install Automator Service application to run your shell code and use the AppleScript code to click the Install button and subsequent Done button on the Service Installer dialog box in the process of installing your Services.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .