Groumphy Posted October 22, 2006 Share Posted October 22, 2006 Hellloooooo everybody, Scripter... I've a problem !, ... I use Autoit for launching applications. These applications are a Web server (ZazouMiniWebServer) and MySQL...I use MS-DOS to launch these applications but now AutoIt.I thus took the following function:; Nom de la fonction : _Start ; Rôle : lancer l'application ; Dépendance : ; Auteur : SvenP (AutoIt Script Forum) ; Modification : ; Version : v1.0.0 ; Information importante : Func _Start($iFileStr) If @OSType = 'WIN32_NT' Then $iStartStr = @ComSpec & ' /c start "" ' Else $iStartStr = @ComSpec & ' /c start ' EndIf Run($iStartStr & $iFileStr, '', @SW_HIDE) EndFunc; ==> _Start("myfile.chm")For start the Web Server this is not a problem... But for start MySQL this is !In the MS-DOS file, I've these instructions : cd mysql\bin\ start mysqld-max --no-defaults --skip-innodb --datadir=..\data --pid-file=NUL cd ..\..\For translate in AutoIt, I do this : ; Nom de la fonction : _MySQLStart ; Rôle : lancer l'application MySQL ; Dépendance : _Start ; Auteur : Groumphy ; Modification : ; Version : v0.2.240.alpha ; Information importante : Func _MySQLStart() Return _Start('mysql\bin\mysqld-max.exe --no-defaults --skip-innodb --datadir=..\data --pid-file=NUL') EndFunc; => _MySQLStart()I've include this code in a GUI (on a button) and when I press the button this launch the function (all flag are OK) but this don't start the MySQLd-Max.exe !I've only a black DOS window... And nothing else...Who can help me ??Thanks, ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
John Posted October 22, 2006 Share Posted October 22, 2006 This is a scipt I wrote for web development on win98. It starts Apache web server invisible when started. Clicking the tray icon gives the option to start MySql. It also includes access to the log files from the tray and kills all web apps prior to exiting. The biggest difference I see is that you are running MySql from a cmd prompt and I run it directly. Mine works perfectly though paths are hard coded and the only GUI is the tray click menu. In case your wondering Drawer.exe is another autoit script that allows me to put icons on the Quick Launch bar that open drawers with groups of applications. It can also be associated with file types when you want a choice of applications to open a particular file type. The ini file requires manual configuration. AutoIt Ver. 3.1.1.132 expandcollapse popup#include <Constants.au3> #NoTrayIcon Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) Dim $act=0 $_Ver = "Ctrl 0.5" If WinExists($_Ver) Then Exit AutoItWinSetTitle($_Ver) TraySetClick(9) TrayCreateItem("Edit Httpd.conf") TrayItemSetOnEvent(-1, "Httpd") TrayCreateItem("View Access Logs") TrayItemSetOnEvent(-1, "Alogs") TrayCreateItem("View Error Logs") TrayItemSetOnEvent(-1, "Elogs") $Tsql=TrayCreateItem("Sql") TrayItemSetOnEvent(-1, "Sql") TrayCreateItem("Exit All") TrayItemSetOnEvent(-1, "Killit") TraySetState() If ProcessExists("mysqld.exe")=0 Then $Sql="Start MySQL" Else $Sql="Kill MySQL" EndIf TrayItemSetText($Tsql, $sql) If ProcessExists("Apache.exe")=0 Then Run('"C:\Program Files\Servers\Apache\Apache2\bin\Apache.exe" -w -f "C:\Program Files\Servers\Apache\Apache2\conf\httpd.conf" -d "C:\Program Files\Servers\Apache\Apache2\."', "C:\Program Files\Servers\Apache\Apache2\", @SW_HIDE) ProcessWait("Apache.exe", 5) EndIf ProcessWaitClose("Apache.exe") If ProcessExists("mysqld.exe")<>0 Then Sql() Exit Func Killit() WinActivate("APACHE") Sleep(500) Send ("^c") EndFunc Func Sql() If ProcessExists("mysqld.exe")=0 Then Run('C:\Program Files\Servers\Apache\MySQL\bin\mysqld.exe --defaults-file="C:\WINDOWS\my.ini"', "C:\Program Files\Servers\Apache\MySQL\bin\") $ret=ProcessWait("mysqld.exe",5) $sql="Kill MySQL" Else ProcessClose("mysqld.exe") $ret=ProcessWaitClose("mysqld.exe",5) $sql="Start MySQL" EndIf TrayItemSetText($Tsql, $sql) EndFunc Func Httpd() Run("C:\Program Files\AutoScipts\Task Drawers\Drawer.exe C:\Program Files\Servers\Apache\Apache2\conf\httpd.conf") EndFunc Func Alogs() Run("C:\Program Files\AutoScipts\Task Drawers\Drawer.exe C:\Program Files\Servers\Apache\Apache2\logs\access.log") EndFunc Func Elogs() Run("C:\Program Files\AutoScipts\Task Drawers\Drawer.exe C:\Program Files\Servers\Apache\Apache2\logs\error.log") EndFunc Link to comment Share on other sites More sharing options...
Groumphy Posted October 22, 2006 Author Share Posted October 22, 2006 Hmmm... Ok, I try this way : 1. write in hard (why not in a variable) the path to the application, 2. use Run at place than a DOS launching, Tomorow I've the result... But here the problem this is a standalone webserver and a standalone database. ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
John Posted October 23, 2006 Share Posted October 23, 2006 No need to hard code the path. I do that sometimes when writing my own stuff for my machine but it is not good practice. I simply copy and pasted code that is working for me on this machine. Running MySql with Run() is preferable though. My webserver and MySql is standalone also. Used for development prior to deployment in a live environment. Link to comment Share on other sites More sharing options...
Groumphy Posted October 23, 2006 Author Share Posted October 23, 2006 Hello, I've try this : Return Run(@ScriptDir & '\mysql\bin\mysqld-max.exe --no-defaults --skip-innodb --datadir=..\data --pid-file=NUL', '', @SW_HIDE, '') but nothing is coming for the process... And no error too ! (no return of RunFatalError !) This is not cooool ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Groumphy Posted October 23, 2006 Author Share Posted October 23, 2006 Hum, I've try this : Return _Start('"' & @ScriptDir & '\mysql\bin\mysqld-max.exe" --no-defaults --skip-innodb --datadir=..\data --pid-file=NUL') Or have the path to mySQL-max.exe in a variable... But this is same GRRRRRRR ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Groumphy Posted December 4, 2006 Author Share Posted December 4, 2006 Hello, I think than I've found the problems : 1. launching the process is not a problem : _Start('mysql\bin\mysqld-max.exe') This execute the process MySqld-max.exe 2. add some argument in the path is not a problem too : _Start('\mysql\bin\mysqld-max.exe --skip-innodb') But if I add an argument with a path : _Start('\mysql\bin\mysqld-max.exe --skip-innodb --datadir=..\data') This doesn't work ! The problem found I much find a solution ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
MHz Posted December 4, 2006 Share Posted December 4, 2006 In your MS-DOS file you cd but you do not show as changing the directory in the AutoIt code. Try passing the working directory in your Run function. _Start('mysqld-max --no-defaults --skip-innodb --datadir=..\data --pid-file=NUL', @ScriptDir & '\mysql\bin') Func _Start($iFileStr, $WDstr = '') If @OSType = 'WIN32_NT' Then $iStartStr = @ComSpec & ' /c start "" ' Else $iStartStr = @ComSpec & ' /c start ' EndIf Run($iStartStr & $iFileStr, $WDstr, @SW_HIDE) EndFunc; ==> _Start("myfile.chm") Link to comment Share on other sites More sharing options...
Groumphy Posted December 22, 2006 Author Share Posted December 22, 2006 It's perfect ! I've the process... I much only find the good arguments and it's ok. A very stupid programming error Sorry for the disturb... ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now