*NOTE:
This wont happen if i replaces row 9 with this:
putserv "PRIVMSG $chan :$contents"
*NOTE
The reason for this is because of the irc protocol, not your code...
You can't send a blank message on irc, thus if $contents is empty, you would be attempting to send an empty message to irc, which you can't do.. by adding $nick to the output, the output to server is no longer empty.
The problem lays in the output relayed from the program you are executing... Thus you should check if $contents is empty or not before sending output to server.
elajt wrote:Thanx! I deleted that while loop, so now it works..
Actually, the problem is (was) due to the fact that you used a "while {![eof $input]}" construction. The eof is only set AFTER the last read. So after a last (unsuccessfull) read, the eof is set and the while loop stops.
If there is a one line file named "testfile.dat", with the one line being "hello world" then running this piece:
set fileid [open testfile.dat r]
while {![eof $fileid]} {
puts "LINE: [gets $fileid]"
}
close $fileid
will produce as output:
LINE: hello world
LINE:
This file reading business is a very good candidate for the TCL FAQ
Additionally and more serious is the fact that you use /bin/date to retrieve the date. On my shell system your code or the [exec /bin/date] against a [clock seconds] combined with a [clock format] runs as:
2400 microseconds per iteration (/bin/date)
23 microseconds per iteration (clock seconds & clock format)
But the date will hang up, hm, how should i explain this, hm, if i type ps ax, at my shell, it will display that the program has become defunct:
#elajt: ps ax |grep date 7621 ? Z 0:00 [date <defunct>]
This is without doubt a security risk, anyone knows how to prevent it?