I wrote a little shell script that switches some settings that I have to switch a lot. I saved it as a .command file, so double-clicking will run it. Now everytime I run it, it's asking for my password (although just changing those settings doesn't require any password when I do it by hand).
Is it possible to make the bash script run, without it asking for a password everytime? All it does is switches my proxy settings off…
The script:
#!/bin/bash
osascript -e 'quit app "MyAppsAnywhere"'
networksetup -setautoproxystate Wi-Fi off
exit 0
Best Answer
You could use
and then configure
sudoers(5)
to allow that exact command (or anynetworksetup
invocation (or any command whatsoever)) without a password, though this generally requires fiddling around withvisudo(8)
and if you get things wrong may lock you out of future use ofsudo(1)
. Open a root shell, make a backup of/etc/sudoers
, edit the file by runningvisudo
, test it, and use root shell to restore the backup of the config if things go awry. Relevantsudoers(5)
config lines would be along the lines ofAlso
visudo
may run a strange editor by default, so you might want to read up on theEDITOR
andDISPLAY
environment variables and relatedsudo
questions and documentation before you get stuck invi
...