Run shell commands in Mac OS X executing a normal application

Once I installed Apache2+MySQL5+PHP5.3 using MacPorts I wanted to start and stop the services without having to open a terminal window a run the commands myself. This can be achieved creating an AppleScript that executes the command and then saving it as an application.

Open the AppleScript editor (Utilities→AppleScript Editor.app) and write the command you want to run. I had to create 4 different applications because I wanted the start and stop applications for both Apache2 and MySQL5. As the commands must be run as an administrator I added at the end “with administrator privileges” (the application will ask for the password):

do shell script "/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start" with administrator privileges
do shell script "/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop" with administrator privileges
do shell script "/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start" with administrator privileges
do shell script "/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop" with administrator privileges

It’s VERY IMPORTANT to clic the “Compile” button to be sure everything is correct and that the application is created. Now you only have to go to “File→Save…” and save it with the “Application” format.

You might also like

Useful Apache 2 and MySQL 5 service aliases for MacPorts
Those are some aliases I use to start, stop and restart Apache 2 and MySQL on my MacPorts installation...
Change root password in MySQL
In GNU/Linux: $ sudo mysqld_safe --skip-grant-tables & $ mysql -u root -p #press enter to use a...
Apache 2 + MySQL 5 + PHP 5.3 + phpMyAdmin 3.5.4 installation script for Mac OS X using MacPorts
Based on the instructions provided by Gilles Fabio I've created a complete installation script to install...
Install MongoDB in Ubuntu 12.04 with PHP driver
Install MongoDB: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 echo...
Leave a comment ?

0 Comments.

Leave a Comment