I’m new to learning apple script and am trying to learn how to create a script that starts/stops Apache2.
I can create an apple script that opens the terminal application, but then how do I get it to do the following:
cd /usr/library/apache2/bin
sudo apachetl start
Then quit the terminal application.
If someone could give me an example to study I would greatly appreciate it!
You should be able to use:
do shell script "apachetl start" with administrator privileges
Thanks Greg,
Here is my script and the error I’m getting:
tell application “Terminal”
activate
do shell script “apachetl start” with administrator privileges
end tell
When I run the script it asks for “administrator password” then I get error:
Terminal got an error:
sudo: apachetl: command not found
Does it work if you include the path to apachectl?
do shell script "/usr/sbin/apachcectl start" with administrator privileges
btw, by using the do shell script command you don’t need to activate the terminal.app