Jump to content
Sign in to follow this  
amuskie

Command Line Redirect Input - file

Recommended Posts

amuskie

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!

Share this post


Link to post
Share on other sites
bo8ster

Try it in a normal dos window first so make sure the command works.

Edited 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]

Share this post


Link to post
Share on other sites
bo8ster

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]

Share this post


Link to post
Share on other sites
amuskie

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\")

Share this post


Link to post
Share on other sites
bo8ster

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 :P

Edited 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]

Share this post


Link to post
Share on other sites
amuskie

Still not working.

Note: Added the mysql path and checked "mysql.exe" works under c:\ if I manually run it under dos prompt.

Share this post


Link to post
Share on other sites
bo8ster

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]

Share this post


Link to post
Share on other sites
amuskie

No space after the "--".

The database/table is specified inside the sql file.

Share this post


Link to post
Share on other sites
bo8ster

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]

Share this post


Link to post
Share on other sites
James

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.

Share this post


Link to post
Share on other sites
twostars

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

Share this post


Link to post
Share on other sites
bo8ster

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]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.