Working in OSX can be a grinding experience for developers with assistance from the OS when you’re running a development machine. One of the niggles for me was having to enter user names and passwords when you start and stop services running on lower port numbers.

I’m not sure of the exact reason for this but can only assume that its because the OS ships with software using the ports. One prime example of this is trying to manage MAMP’s embedded Apache server running on port 80.
You can avoid the authentication by having an automator script do the work for you. Here are 2 examples of scripts to start/stop a local MAMP setup
on run {input, parameters}
do shell script "sudo /Applications/MAMP/Library/bin/apachectl
-k start" password "password" user name "username"
with administrator privileges
do shell script "/Applications/MAMP/Library/bin/mysqld_safe
--port=3306
--socket=/Applications/MAMP/tmp/mysql/mysql.sock
--lower_case_table_names=0
--pid-file=/Applications/MAMP/tmp/mysql/mysql.pid
--log-error=/Applications/MAMP/logs/mysql_error_log &"
return true
end run
and to stop the services…
on run {input, parameters}
do shell script "sudo /Applications/MAMP/Library/bin/apachectl
-k stop" password "password" user name "username"
with administrator privileges
do shell script "/Applications/MAMP/Library/bin/mysqladmin
-u root -proot
--socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown"
return input
end run
The one problem I’ve found is that once you run the start script, you do tend to get an applescript running icon for a while, but as long as this doesn’t bother you then problem solved.



