Friday, January 19, 2018

#1 2003-05-29 09:38:58 am

Ray Barber
Site Admin
From:: Lake Dallas, Texas
Registered: 2002-11-20
Posts: 348
Website

Serve on!...or serve off.

This small AppleScript can be placed in the Dock, allowing one-click launching and terminating of Apache. One caveat: In order for this to work, you have to edit /etc -> sudoers to give yourself the ability to launch Apache without having to enter your password -- see man sudoers for help with that process. That's a potential security risk, but as I see it, it's no riskier than allowing System Prefs to launch it via a button. 

OS version: OS X

Applescript:

do shell script "sudo /usr/sbin/apachectl stop"
if result = "/usr/sbin/apachectl stop: httpd (no pid file) ¬
not running"
then
do shell script "sudo /usr/sbin/apachectl start"
display dialog "Apache Started" with icon 2 buttons ¬
{"OK"} giving up after 1
else
display dialog "Apache Stopped" with icon 2 buttons ¬
{"OK"} giving up after 1
end if


Ray Barber
Admin | MacScripter

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)