amuskie Posted March 10, 2009 Share Posted March 10, 2009 I failed to insert new record to MySQL database thru command line: RUN("C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe --user=root -- password=root_pwd < c:\new_rec.sql") If I remove use this one: RUN("C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe --user=root -- password=root_pwd") I could get the MySQL console prompt and it seem the redirect "< c:\new_rec.sql" having problem. Any idea how to solve it? Thanks! Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 (edited) Try it in a normal dos window first so make sure the command works. Edited March 10, 2009 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
amuskie Posted March 10, 2009 Author Share Posted March 10, 2009 It works under DOS without any problem. Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 Try Run("mysql.exe --user=root -- password=root_pwd < c:\new_rec.sql", "C:\Program Files\MySQL\MySQL Server 5.1\bin") The spaces in the path might be causing issues. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
amuskie Posted March 10, 2009 Author Share Posted March 10, 2009 No luck under: Run("mysql.exe --user=root -- password=root_pwd < c:\new_rec.sql", "C:\Program Files\MySQL\MySQL Server 5.1\bin") or Run("mysql.exe --user=root -- password=root_pwd < c:\new_rec.sql", "C:\Program Files\MySQL\MySQL Server 5.1\bin\") Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 (edited) Ok Put "C:\Program Files\MySQL\MySQL Server 5.1\bin" on the path so when you type mysql --version in a cmd window it works. Then try this Run(@ComSpec & " /c mysql.exe --user=root -- password=root_pwd < new_rec.sql", "c:\") Hope that works Edited March 10, 2009 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
amuskie Posted March 10, 2009 Author Share Posted March 10, 2009 Still not working. Note: Added the mysql path and checked "mysql.exe" works under c:\ if I manually run it under dos prompt. Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 Quick question, is the space required between the -- and password? This should be --password instead of -- password like you have for user? You may also need to specify the database to which the sql file is to be applied on. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
amuskie Posted March 10, 2009 Author Share Posted March 10, 2009 No space after the "--". The database/table is specified inside the sql file. Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 I'm sorry mate, i'm starting to run out of ideas. I hate it when code should work, but does not. I just know its something small. I don't have mysql to test out on either. I would look to a MVP for a solution -- they are good with this type of stuff. Anyone got any ideas? Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
James Posted March 10, 2009 Share Posted March 10, 2009 Try this, I had a similar problem. Run(@ComSpec & " mysql.exe --user=root -- password=root_pwd < new_rec.sql", "c:\") If not that, then perhaps this. Run("mysql.exe --user=root -- password=root_pwd < new_rec.sql", "c:\") And if not that then I will look more when I have time to test. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
twostars Posted March 10, 2009 Share Posted March 10, 2009 Try this, I had a similar problem. Run(@ComSpec & " mysql.exe --user=root -- password=root_pwd < new_rec.sql", "c:\") If not that, then perhaps this. Run("mysql.exe --user=root -- password=root_pwd < new_rec.sql", "c:\") And if not that then I will look more when I have time to test.What? You're adding a space after the "--" and before "password". This should also work (in Debian that works, not too sure about Windows though - should be no different): mysql -uroot -proot_pwd < new_rec.sql Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 I see your point but this is not Debin, it is windows. amuskie says it works in a cmd window with spaces so it should work with spaces in AutoIt. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] 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