XAMPP AppleScript Controller

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

XAMPP AppleScript Controller

Postby tomservo291 » 18. November 2006 21:18

I just started using XAMPP on 10.4.8 and like it; I was using the built in Apache install and MySQL but I like this solution better for development.

I learned of XAMPP on windows, and am sad to see there is no easy-to-use GUI for controlling the services, and have found few working/easy solutions. I ran accross the guy who had screenshots up last year and never got to finish his, which looked nice; but I don't have time to do something like that at the moment.

I made a quick AppleScript app based loosely around someone elses grep command that I ran accross that makes things a little more intuitive. It can be used standalone, or you could easily put it in your startup items (I have it sitting in my Atomic Beef launch bar.)

Code: Select all
--
-- XAMPP AppleScript Controller
--
-- Alexander Sherwin
-- alex.sherwin@gmail.com
--
-- v1.0 created 11/18/06
--

set isAppleApacheRunning to 1
set isXamppApacheRunning to 1

-- Apple Apache check
try
   set s to do shell script "ps -ax | grep /usr/sbin/httpd|grep -v grep"
on error errMsg number errNum
   set isAppleApacheRunning to 0
end try

-- XAMPP Apache check
try
   set s to do shell script "ps -ax | grep /Applications/xampp/xamppfiles/bin/httpd|grep -v grep"
on error errMsg number errNum
   set isXamppApacheRunning to 0
end try

if isAppleApacheRunning is 1 then
   set dialogReply to display dialog ¬
      "Apple's Apache is running.  Stop this process first." buttons {"Exit"} default button 1
   return
end if

-- If XAMPP is not running
if isXamppApacheRunning is 0 then
   set dialogReply to display dialog ¬
      "XAMPP is not running." buttons {"Start", "Exit"} default button 1
   if button returned of dialogReply is "Start" then
      do shell script ¬
         "/Applications/xampp/xamppfiles/mampp start" with administrator privileges
      return
      
   else if button returned of dialogReply is "Exit" then
      return
      
   end if
end if

-- If XAMPP is running
if isXamppApacheRunning is 1 then
   set dialogReply to display dialog ¬
      "XAMPP is currently running." buttons {"Stop", "Restart", "Exit"} default button 1
   
   if button returned of dialogReply is "Stop" then
      do shell script ¬
         "/Applications/xampp/xamppfiles/mampp stop" with administrator privileges
      return
      
   else if button returned of dialogReply is "Restart" then
      do shell script ¬
         "/Applications/xampp/xamppfiles/mampp restart" with administrator privileges
      
   else if button returned of dialogReply is "Exit" then
      return
      
   end if
end if
tomservo291
 
Posts: 6
Joined: 18. November 2006 21:00

...

Postby bjeanes » 23. November 2006 12:21

That's kinda funny. I'm the guy who posted those screenshots. I got a mac a few months back and finally got some work done on the project.

See here: http://community.apachefriends.org/f/viewtopic.php?p=90009

In fact. I had a quick spin through your applescript here and was wondering if you mind if I add this into the CP. It'd be just so you could easily see what is already enabled/disabled. I was planning to do something like this but didn't have the time to invest the mental energy needed to figure it out. Everything I did last few weeks was mostly grunt work.

This could definately improve the CP, though, for everybody. I am also recommending that your dashboard widget be included with the next release. I don't personally use the dashboard ... ever ... but your widget makes me reconsider it :-)

Bo
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 4 guests