b0br0ff Posted December 13, 2011 Share Posted December 13, 2011 (edited) Hi, I am trying to perform very easy stuff with AutoIT, i.e. to execute simple SQL query on the MySQL server and save results to the text file. Code sample: Local $sCmd = @ComSpec & " /c """ & $MySqlPath &"bin""mysql.exe" $sCmd = $sCmd & " --host=" & $host $sCmd = $sCmd & " --user=" & $user $sCmd = $sCmd & " --password=" & $passwd $sCmd = $sCmd & " --port=" & $port $sCmd = $sCmd & " < C:tempsql1.txt" $sCmd = $sCmd & " > C:temp2.txt" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sCmd = ' & $sCmd & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$sCmd' & @lf & @lf & 'Return:' & @lf & $sCmd) ;### Debug MSGBOX Local $val = RunWait($sCmd, "", @SW_MAXIMIZE) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $val = ' & $val & @crlf & '>Error code: ' & @error & @crlf) ;### Debug ConsoleProblem is that output file is always created empty, however when I execute same command in CMD everything is ok.C:Usersuser>"C:Program FilesMySQLMySQL Server 5.5bin"mysql.exe --host=localhost --user=root --password= --port=3306 < C:tempsql1.txt > C:temp2.txtThank You in advance! Edited December 13, 2011 by b0br0ff Link to comment Share on other sites More sharing options...
willichan Posted December 13, 2011 Share Posted December 13, 2011 RunWait will not give you the text output on the console by the command you run with it. It will only give you the return code, if there is one.Take a look at It was very helpful for me. b0br0ff 1 My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
kylomas Posted December 13, 2011 Share Posted December 13, 2011 b0br0ff, When run from the command line you are piping the output to a file. When run from the script you are doing nothing with the output, as WillChan alluded to. See STDOUTREAD in the help file, if you want to stay with your current method. kylomas b0br0ff 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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