This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

DoEvents() function in TCL like in Visual Basic ???

Old posts that have not been replied to for several years.
Locked
D
D4RkViP3R
Voice
Posts: 7
Joined: Mon Jun 13, 2005 7:18 am
Location: Isenbüttel, Lower Saxony, Germany

DoEvents() function in TCL like in Visual Basic ???

Post by D4RkViP3R »

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: Select all

# 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
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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
t
tonyrayo
Voice
Posts: 20
Joined: Thu Jul 31, 2003 3:29 pm
Location: Waldorf, MD
Contact:

Post by tonyrayo »

demond wrote: you aren't Deutsche Bank are you
Maybe he is =p
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

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.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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]
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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

so just read my previous "you can run TCL scripts asyncronly!" as a "you can query it asyncronly as an external TCL script!" :D
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...
Locked