View Single Post
  #6  
Old 06-21-2007, 07:41 AM
nicobos nicobos is offline
Registered User
 
Join Date: Jun 2007
Location: Netherlands
Posts: 6
I figured it out.
From Applescript you can run a shell command authenticated as a certain user.
From shell you can run Applescript commands.
This can combined in a shellscript like:

#!/bin/tcsh -f
osascript -e 'do shell script "echo " & "MySQL is being stopped"'
osascript -e 'do shell script "/Library/StartupItems/MySQLCOM/MySQLCOM stop" user name "root" password "my secret password" with administrator privileges'
osascript -e 'do shell script "echo "& "Wait 10 seconds"'
osascript -e 'delay 10'
osascript -e 'do shell script "echo "& "MySQL databases are being copied"'
osascript -e 'do shell script "cp -f -R /usr/local/mysql-max-5.0.27-osx10.4-i686/data /usr/local/mysql-max-5.0.27-osx10.4-i686/data_backup" user name "root" password "my secret password" with administrator privileges'
osascript -e 'do shell script "echo "& "Waits 10 seconds"'
osascript -e 'delay 10'
osascript -e 'do shell script "echo "& "MySQL is being started"'
osascript -e 'do shell script "/Library/StartupItems/MySQLCOM/MySQLCOM start" user name "root" password "my secret password" with administrator privileges'

Don't forget to chmod 755 the shell script file, otherwise you will get a permission error.

Nico
Reply With Quote