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.

Fileevent problem..

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Fileevent problem..

Post by Ofloo »

File event problem this thing blocks untill the executed file has ended .. why is that ?? ive tryed using fconfigure -blocking 0 -buffering line and no result ..

Code: Select all

bind pub - !run runtest

proc runtest {nick host hand chan arg} {
  set exec [open |file.exe r+]
  fileevent $exec readable runresult [list $exec $nick]
}

proc runresult {f nick} {
  if {![eof $f]} {
    close $f
    putserv "NOTICE $nick :File ended."
  }
}
XplaiN but think of me as stupid
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You're never reading from the file.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

what do you mean ?? it is a test proc eh do you mean it won't work cause i am not reading or do you mean it is pointless you are not reading ?? cause i tryed adding gets $ef line and no result so.. also i am not planning on reading from the file i want to see when the file ends thats it
XplaiN but think of me as stupid
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Why don't you add some putlogs to it? It seems to me like it will run continuously, because you never read from it. As long as there is data to read, you don't have eof.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

hmm well it works it does what it is supposed to do the problem is that it freezes untill it ends .. i tryed reading from it tho .. gets $ef line right that would be reading ..

also if i open a while the while will occupy the bot untill it is done reading untill the end of the file so untill its done executing witch means it is frozen untill the executed file ends witch in the end is the same as i got now ..

i just wana execute something in background and when it finishes i want the bot to notify me .. thats it but without blocking the bot ..
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i found out what the problem is eof is blocking not fileevent .. for some reason it is waiting untill it is finished ..
XplaiN but think of me as stupid
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Ofloo wrote:i found out what the problem is eof is blocking not fileevent .. for some reason it is waiting untill it is finished ..
post it if you find it, should be interesting
PS: No, i'm not dead, just in middle of my final exams
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

k ;)
XplaiN but think of me as stupid
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Or you could just look at how I did it in my bgexec.tcl script...
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

first of all nice script there is a small problem this is just to exec something in bg mode not to see when something ends while eof is causing the problem not fileevent it executs in bg mode but eof is blocking waiting untill the file ends even if it is a other proc .. instead of going true and returning so i can call it back no it blocks and waits .. if i would use eof in this script it would block as well..
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

crap i fixed it lol and you where right stdragon reading from the channel helped altho the responds is way later then it is supposed to .. the file ends now and like a minute later the eof responds.

Code: Select all

bind pub - !run runtest 

proc runtest {nick host hand chan arg} { 
  set exec [open |file.exe r+] 
  fileevent $exec readable runresult [list $exec $nick] 
} 

proc runresult {f nick} { 
  if {[eof $f]} { 
    close $f 
    putserv "NOTICE $nick :File ended." 
    return
  } 
  gets $f line
}
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

And i found out why you where right sinds the executed file is buffering the values the exe returns .. and loops true its proc and as long as the buffer remains there won't be an end of file and it will not return that either.

now my second problem the buffer becomes to big witch means that the end of file is way later then the real file so .. ok it works but how do i minize thes buffer or how do i set a max buffer ..
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

The buffering wasn't working and read didn't work either not like it should anyway so i found an other solution you could say threads..

basicly i can read from the bin file and i know when it ends .. i gues the more intensive it gets the more you incrase the value of "i" but this is pretty intence exe so ..

Code: Select all

bind pub - !run runtest 

proc runtest {nick host hand chan arg} { 
  set exec [open |file.exe r+] 
  fileevent $exec readable runresult [list $exec $nick $chan] 
} 

proc runresult {f nick chan} { 
  if {[eof $f]} { 
    close $f 
    putserv "NOTICE $nick :File ended." 
    return 
  } 
  for {set i 0} {$i < 50} {incr i} {
    gets $f x($i)
  }
  foreach s [array get x] {
    if {[string match -nocase *result string* $s]} {
      putserv "PRIVMSG $chan :$s"
    }
  }
}
XplaiN but think of me as stupid
Locked