Jump to content

Connecting to MySQL through cmd via autoIt v3


 Share

Recommended Posts

Hello guys,

Well, i was introduced to AutoIT v3 2 days ago, and i have to say that i absolutely love it. it has enabled me to automate my many boring little annoying tasks.

My problem is the following;

- installed on my machine is mysql server, and all the environment variables are nicely set.

- i wish to do the following;

RunWait("mysql -u root -p")

WinWaitActive("C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe")

send("password")

send("{enter}")

send("create user is3;")

send("{enter}")

send("GRANT ALL PRIVILEGES ON *.* TO is3@%")

send("{enter}")

send("IDENTIFIED BY WITH GRANT OPTION;")

send("{enter}")

send("quit")

send("{enter}")

The code seems quite straightforward... but it doesn't work the first time i run the script, always works the second time.

Now i've spent the last hour searching the forum for a similar problem, but couldn't find much... i'm really sorry if this has been sorted somewhere else... if that the case, i would really appreciate the link.

Kinda regards,

Simon

Link to comment
Share on other sites

this might get you started....

AutoItSetOption("WinTitleMatchMode", 2)
Run(@ComSpec & " /c " & "C:\xampplite\mysql\bin\mysql -u root -p")
WinWaitActive("cmd.exe")
send("password")
send("{enter}")
send("create user is3;")
send("{enter}")
send("GRANT ALL PRIVILEGES ON *.* TO is3@%")
send("{enter}")
send("IDENTIFIED BY  WITH GRANT OPTION;")
send("{enter}")
send("quit")
send("{enter}")

> there are 10 types of people in the world, those who understand binary and those who don't.

Link to comment
Share on other sites

this might get you started....

AutoItSetOption("WinTitleMatchMode", 2)
Run(@ComSpec & " /c " & "C:\xampplite\mysql\bin\mysql -u root -p")
WinWaitActive("cmd.exe")
send("password")
send("{enter}")
send("create user is3;")
send("{enter}")
send("GRANT ALL PRIVILEGES ON *.* TO is3@%")
send("{enter}")
send("IDENTIFIED BY  WITH GRANT OPTION;")
send("{enter}")
send("quit")
send("{enter}")
Thank you Jinxter for your prompt answer,

i'm sorry to say that it didn't work. The Run statement opens a cmd and closes it almost instantly.

and (i'm not sure) but because of the wintitlematchmode = 2, it is causing the "send" messages to be received by all other opened windows that has any of key words in WinWaitActive.

Cheers,

Simon

Link to comment
Share on other sites

Thank you Jinxter for your prompt answer,

i'm sorry to say that it didn't work. The Run statement opens a cmd and closes it almost instantly.

and (i'm not sure) but because of the wintitlematchmode = 2, it is causing the "send" messages to be received by all other opened windows that has any of key words in WinWaitActive.

Cheers,

Simon

In addition to above the problem seems in general with sending messages to cmd.

eg:

RunWait("cmd.exe")

WinWaitActive("C:\WINDOWS\system32\cmd.exe")

send("dir c:\")

the cmd window did open successfully, but the "dir c:\" msg did't go through

Cheers,

Link to comment
Share on other sites

Don't use RunWait() cause you stop there waiting.

try your original code with Run().. or find the mysql UDFs that were written for people like you.

Lar.

It's makes perfect sense... i totally misunderstood wat RunWait() does.

Run() works perfectly :whistle:.. Lar... ur the man..

As for the UDFs, from what i've read so far, it requires an ODBC (or other type) bridge to be installed on the system. i can install it, but i have to assume that it doesn't exist.

Again, Thanks for the help...

cheers,

Simon

Link to comment
Share on other sites

hmmm... I made an error I see ...

I used the path to my mysql executable, that's why it didn't work... Sowwy :whistle:

edit it to match your path and it should do as you want ;)

> there are 10 types of people in the world, those who understand binary and those who don't.

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...