Running sudo commands in Automator

If you’re wondering how to run sudo (for privilege escalation) commands in Automator, this is one way to do it.

Launch up Automator (of course).


Find Run AppleScript in the library of actions.


Then, drag it over to the workflow area on the right. By default, Automator will put in some script structure for you to work with. Feel free to just delete that all completely.


In place of the predefined script, put in

do shell script “sudo whatevercommandyouwanttorun” with administrator privileges

if it’s one command you want to run.

If you would rather run a script, it’s a similar syntax of

do shell script “sudo /path/to/youractualscript.sh” with administrator privileges


You can save your workflow as an application.


When you double-click your .app file, it should then prompt you for an administrator username and password and then run your bash command or shell script in a sudo-like way.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *