Jump to content

How to run a script that asks authorization

Recommended Posts


I am writing a workflow to unload tun and tap. Here my script action:




sudo kextunload -b foo.tun
sudo kextunload -b foo.tap
The problem is that terminal asks me a password (my account password). I don't know how to bypass the authorization step. After that, the workflow would open an VPN application.
I am using different VPN programs that probably active tun and tap every time I restart my laptop. 
Any ideas? Thanks!
Link to comment

If you want to run a script as a superuser, you can wrap your command in the following AppleScript:

do shell script "kextunload -b foo.tun; kextunload -b foo.tap" with administrator privileges

It will prompt for authentication. You can put this code in an NSAppleScript object or a Run Script object with the language set to 'osascript'.


Jonas Eriksen posted this before


I don't know of any way to completely bypass authentication, but this is a simple way to run sudo commands.

Edited by Tyler Eich
Link to comment

To get around the authorization using sudo commands, you'll need to add a line to your sudoers file. You can't expect people to do this on their own machines, so if you want to do so, then add it in the instructions. Be careful when editing your sudoers file, however, because you can break a lot of things easily. If you want to just do it on your own and are nervous about doing so, then download my sudoers workflow, and then use that for your user account.


If you want a way to implement the sudo command in a script, then download my DHCP Toggle workflow, and check out the code there. There are some comments in it that workflow that can help you out.


But, again, be careful with sudo.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...