Applescript to start and stop XAMPP

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

Applescript to start and stop XAMPP

Postby jksellors » 05. August 2005 20:47

Hi,
I have downloaded and installed XAMP on a Mac dual using OS X 10.4.2 and I have installed Xaraya as my first site install test. Everything went fine. I have run the sudo su ----Applications/xampp/xamppfiles/mampp security in the Terminal application to make all the securities warnings green.
I would like to thank the Apache Friends for this package it is very good and saves a lot of time.
I have written an Applescript to start and stop XAMPP. I just place it in the Scripts Menu. One problem that I have not solved yet is that it will not start XAMPP if Personal Web Sharing is "on" in the System Preferences/Sharing folder. I think it should be set to "off" anyway. Can You have XAMPP and Apples Personal Web Sharing (Apache 1.3) running at the same time? The script just checks for instances of httpd processes running and can not distinguish were the process is coming from.
Start script:
try
set httpdstatus to do shell script "ps -ax|grep httpd|grep -v grep"
set status to "XAMPP seems to be running"
set ButtonText to "Stop XAMPP"
on error
set status to "XAMPP does not seem to be running"
set ButtonText to "Start XAMPP"
end try
set dialogReply to display dialog status & " — Do you want to start or stop XAMPP?" buttons {ButtonText, "Cancel"} default button 1
if button returned of dialogReply is "Stop XAMPP" then
do shell script " /Applications/xampp/xamppfiles/mampp stop" with administrator privileges -- stop xampp
else
do shell script " /Applications/xampp/xamppfiles/mampp start" with administrator privileges -- start xampp
end if

--end of script.
Copy this to the Script Editor in the Applications/Applescript/ folder and save it to Library/Scripts folder.
The script Menu is activated using the AppleScript Utility application in Applications/Applescript/ folder in Tiger.
__Jeremy
jksellors
 
Posts: 7
Joined: 05. August 2005 19:05

RE: Applescript to start and stop XAMPP

Postby pciar » 07. August 2005 11:38

Very cool. Thanks.
pciar
 
Posts: 2
Joined: 28. June 2005 03:09
Location: Kenosha WI

Postby jksellors » 08. August 2005 01:24

Thanks for the compliment. I have added restart XAMPP and the script now checks if the Apple Apache is running or not.
Code: Select all
set Check to 0
try
   set s to do shell script "ps -ax | grep /usr/sbin/httpd|grep -v grep"
on error errMsg number errNum
   set Check to 1
end try
if Check is 0 then
   display dialog "Apple's Apache is running! Please turn it off in the System Preferences first then rerun this script."
   return
end if
try
   set httpdstatus to do shell script "ps -ax | grep /Applications/xampp/xamppfiles/bin/httpd|grep -v grep"
   set dialogReply to display dialog "XAMPP's Apache is running — Do you want to Stop or Restart XAMPP?" buttons {"Stop", "Restart", "Cancel"} default button 1
   if button returned of dialogReply is "Cancel" then
      return
   end if
on error
   set status to "XAMPP does not seem to be running"
   set dialogReply to display dialog " XAMPP's Apache is not running— Do you want to start XAMPP?" buttons {"Start", "Cancel"} default button 1
   if button returned of dialogReply is "Cancel" then
      return
   end if
end try
if button returned of dialogReply is "Stop" then
   do shell script " /Applications/xampp/xamppfiles/mampp stop" with administrator privileges -- stop xampp
else
   if button returned of dialogReply is "Restart" then
      do shell script " /Applications/xampp/xamppfiles/mampp restart" with administrator privileges -- restart xampp
      
   else
      if button returned of dialogReply is "Start" then
         do shell script " /Applications/xampp/xamppfiles/mampp start" with administrator privileges -- start xampp
      end if
   end if
end if
activate
display dialog "Finished Action!" giving up after 5
jksellors
 
Posts: 7
Joined: 05. August 2005 19:05

Postby robelkin » 18. August 2005 19:48

what about using this script to run at startup? is that possible?
robelkin
 
Posts: 1
Joined: 18. August 2005 19:07


Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 77 guests