| View previous topic :: View next topic |
| Author |
Message |
D4RkViP3R Voice
Joined: 13 Jun 2005 Posts: 7 Location: Isenbüttel, Lower Saxony, Germany
|
Posted: Tue Aug 23, 2005 8:46 pm Post subject: DoEvents() function in TCL like in Visual Basic ??? |
|
|
Hi @ all
I've a problem with a script who's making sql-query on a MySQL server.
There are 106.976.536 entries in the table. It should require 5 - 6 minutes until the result is coming. At this matter of time most IRC Servers would give a ping timeout and kicks the eggdrop.
Is it possible to execute the querycommand in background while asking the MySQL server?
| Code: | # This is a database queryscript above this snip is the mysql
connection declared...
proc searchmd5hash {nick uhost hand chan rest} {
global db_handle
set passtype [string tolower [lindex $rest 0]]
set hash [string tolower [lindex $rest 1]]
switch -exact -- $passtype {
brute { set sql_table "md5_hashes_brute" }
dict { set sql_table "md5_hashes_dict" }
num { set sql_table "md5_hashes_num" }
default {
putchan $chan "Bitte wählen Sie einer der folgenden Möglichkeiten: brute, dict, num"
exit 0
}
}
set sql_cmd "SELECT * FROM `$sql_table` WHERE `hash` LIKE '$hash'"
set result [mysqlquery $db_handle $sql_cmd]
# At the line above, the eggdrop hangs sometimes 5-6 minutes and mostly the IRC Server shows a timeout and kicks the eggdrop.
# How can I put this command into the background and let the eggdrop runs free until the mysql-request is answered.
if {[set row [mysqlnext $result]] != ""} {
set id [lindex $row 0]
set wert [lindex $row 1]
putchan $chan "Gesuchter Wert für den HASH\0034 $hash\003 ist:\0034 $wert\003 $id"
} else {
putchan $chan "Der Wert für den MD5 HASH\0034 $hash\003 wurde in der Datenbank\0034 md5_hashes_dict\003 leider nicht gefunden."
}
}
|
Kind regards,
D4RkViP3R |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Aug 23, 2005 10:43 pm Post subject: |
|
|
there is, but you can't access mysql database asynchronously (there isn't a callback mechanism that you could utilize to take care of your waiting eggdrop events); of course, you can spawn another process to handle the mysql stuff, but then you'll have to implement a synchronization mechanism
you better redesign the database, over 100 million records in a table is ridiculous, you aren't Deutsche Bank are you |
|
| Back to top |
|
 |
tonyrayo Voice
Joined: 31 Jul 2003 Posts: 20 Location: Waldorf, MD
|
Posted: Wed Aug 24, 2005 1:25 am Post subject: |
|
|
| demond wrote: | | you aren't Deutsche Bank are you |
Maybe he is =p |
|
| Back to top |
|
 |
stdragon Owner

Joined: 23 Sep 2001 Posts: 959
|
Posted: Sun Sep 04, 2005 10:24 pm Post subject: |
|
|
As demond suggested, the easiest way is to use another process via exec or open. This can even be another tcl script, so you can still use your existing code and mysql package if you want.
On the other hand, why are you doing a wildcard search against hashes? Seems pretty weird. Since this is such a specific datatype, you could probably make your own specialized lookup functions and it would go a lot faster, especially since you only return the first result anyway.
But really... you should just try changing LIKE to =, and see how much faster it is. And make sure you have an index in your db. |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sun Sep 04, 2005 10:53 pm Post subject: |
|
|
heh, I didn't notice that guy is actually interfacing some kind of password cracker db
anyway, [fork] Tcl command would be useful here (I once wrote [fork] for the sole purpose of changing eggdrop PID hehe) - fetch db data in the child process, save it to file, notify parent, [exit] |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Sep 08, 2005 6:19 am Post subject: |
|
|
you can run TCL scripts asyncronly!
open the tclsh8.4 with open, fconfigure the handle to nonblocking, dump the query part via puts and wait via fileevent readable for the resaults!
But a warning, if you are on a shared shell box your provider might cancel the contract due to much resource usage. I mean... 5min for a tcl/sql executing? wtf? Either the shell is slow as hell or you are sucking the poor machine out ^-^. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Thu Sep 08, 2005 11:44 am Post subject: |
|
|
that wasn't the issue, you prolly didn't pay too much attention to the previous posts
the issue is you can't run mySQL queries asynchronously, not Tcl scripts - which has nothing to do with Tcl |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Sep 08, 2005 12:37 pm Post subject: |
|
|
yeah, I forgot about the detail after reading through in a hurry, but nethertheless you can access the mysql ansycronly to the bot that way .
so just read my previous "you can run TCL scripts asyncronly!" as a "you can query it asyncronly as an external TCL script!"  _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
|