egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
D4RkViP3R
Voice


Joined: 13 Jun 2005
Posts: 7
Location: Isenbüttel, Lower Saxony, Germany

PostPosted: Tue Aug 23, 2005 8:46 pm    Post subject: DoEvents() function in TCL like in Visual Basic ??? Reply with quote

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Aug 23, 2005 10:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
tonyrayo
Voice


Joined: 31 Jul 2003
Posts: 20
Location: Waldorf, MD

PostPosted: Wed Aug 24, 2005 1:25 am    Post subject: Reply with quote

demond wrote:
you aren't Deutsche Bank are you

Maybe he is =p
Back to top
View user's profile Send private message Visit poster's website
stdragon
Owner


Joined: 23 Sep 2001
Posts: 959

PostPosted: Sun Sep 04, 2005 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sun Sep 04, 2005 10:53 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Sep 08, 2005 6:19 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Thu Sep 08, 2005 11:44 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Sep 08, 2005 12:37 pm    Post subject: Reply with quote

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

so just read my previous "you can run TCL scripts asyncronly!" as a "you can query it asyncronly as an external TCL script!" Very Happy
_________________
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
View user's profile Send private message MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber