Jump to content

Command Line Redirect Input - file


Recommended Posts

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

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]

Link to comment
Share on other sites

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

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

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]

Link to comment
Share on other sites

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

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

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...