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.

qstats4eggdrop

Support & discussion of released scripts, and announcements of new releases.
Post Reply
F
FuE-
Halfop
Posts: 57
Joined: Sat Nov 27, 2004 3:46 pm

qstats4eggdrop

Post by FuE- »

hi when i use !cs ip:port i get this in partyline

Code: Select all

(01:05:55) (_aLexi) [01:05] Tcl error [pub:qstat]: couldn't duplicate input handle: bad file number
What can be wrong?

Code: Select all

# $Id: qstat.tcl,v 1.3 2003/06/22 12:43:47 peter Exp $

# Qstat script for an eggdrop, version 2.2, 22/06/2003 
# 
# This script will query gameservers using the qstat program to
# display server status and players using public commands. 
#
# History:
#  1.0 (original) by Mikael Blomqvist <micke@peachpuff.com>
#  1.5 by ST8 <st8@q3f.net> and in part by Ad <ad@contempt.org.uk>
#  1.7 by Peter Postma <peter@webdeveloping.nl>
#    - security hole fixed. (passing bad arguments to TCL's exec)
#    - display players fixed. 
#  1.8 Peter Postma <peter@webdeveloping.nl>
#    - doesn't need a temp file anymore to display player info
#    - use regsub for input checking 
#    - better error checking / error messages
#    - lot of clean up
#  2.0 by Peter Postma <peter@webdeveloping.nl>
#    - very nasty bugs fixed: endless long flood and bad errors
#    - wiped out alot code, rewrote the main function
#  2.1 by Peter Postma <peter@webdeveloping.nl>
#    - support for RTCW, Quake 1
#    - installation steps added :^)
#    - windrop fix (but still doesn't work perfect)
#  2.2 by Peter Postma <peter@webdeveloping.nl>
#    - added BF, Gamespy, QW and UT2003.
#    - added '-timeout 5' option in qstat exec
#
# Installation steps:
# 1) Easiest way of installing: put all Qstat related files (players.qstat, 
#    server.qstat, qstat.tcl, qstat (executable)) into _ONE_ directory.
#    A good choice would be something like: /home/name/eggdrop/qstat 
#    or c:/windrop/qstat
# 2) Download the Qstat program from www.qstat.org and install it
#    to some directory on your system. 
# 3) Change the option "set pathqstat "/home/peter/AI/scripts/my/qstat" 
#    and set it to the path where the Qstat related files are installed.
# 4) Make sure the path you've just set also contains the files:
#    players.qstat & server.qstat. If not, copy them to that directory.
# 5) Optionally change some other configuration settings below.
# 6) Edit your eggdrop's configuration file and add the qstat.tcl script. 
#    If you don't how to do this, please RTFM :)
# 7) Rehash
# 8) Typ !qstat in the channel for a command list.
# 9) Have fun :)
#
# Configuration settings:

# Flags needed to use the commands
set qstat_flag "-|-"

# Path to qstat folder containing qstat stuff/scripts and the qstat program
set pathqstat "C:/SL/scripts/srv/qstat/"

# Channels you _dont_ want the bot to reply to public triggers on 
# (seperate with spaces):
set nopub ""

# End configuration settings



################################################################
# This is where the evil TCL code starts, read at your peril!  #
################################################################

set qversion "2.2"

bind pub $qstat_flag "!ut"  pub:qstat
bind pub $qstat_flag "!hl"  pub:qstat 
bind pub $qstat_flag "!cs"  pub:qstat
bind pub $qstat_flag "!qw"  pub:qstat
bind pub $qstat_flag "!q1"  pub:qstat 
bind pub $qstat_flag "!q2"  pub:qstat 
bind pub $qstat_flag "!q3"  pub:qstat 
bind pub $qstat_flag "!rcw" pub:qstat
bind pub $qstat_flag "!bf"  pub:qstat
bind pub $qstat_flag "!gs"  pub:qstat
bind pub $qstat_flag "!ut2k3"  pub:qstat
bind pub $qstat_flag "!ut2003" pub:qstat

bind pub $qstat_flag "!utp"  pub:qstat
bind pub $qstat_flag "!hlp"  pub:qstat
bind pub $qstat_flag "!qwp"  pub:qstat
bind pub $qstat_flag "!q1p"  pub:qstat
bind pub $qstat_flag "!q3p"  pub:qstat
bind pub $qstat_flag "!q2p"  pub:qstat
bind pub $qstat_flag "!rcwp" pub:qstat
bind pub $qstat_flag "!bfp"  pub:qstat
bind pub $qstat_flag "!ut2k3p"  pub:qstat
bind pub $qstat_flag "!ut2003p" pub:qstat

bind pub $qstat_flag "!qstat" pub:qstat_help

proc pub:qstat_help {nick host hand chan arg} {
  global pathqstat nopub

  # check if channel is allowed.
  if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}

  # output qstat commands / help.
  putserv "NOTICE $nick :Qstat commands:"
  putserv "NOTICE $nick :\002!qw / !q1 / !q2 / !q3 / !rcw <ip/host>\002 - Displays status of queried Quake World, 1, 2, 3 or RTCW servers"
  putserv "NOTICE $nick :\002!ut / !ut2003 / !hl / !bf / !gs <ip/host>\002 - Displays status of queried UT(2003), Half-life, BF1942 and GameSpy servers"

  return 0
}

proc pub:qstat {nick host hand chan arg} {
  global lastbind pathqstat nopub

  # check if channel is allowed.
  if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}

  # only use one argument.
  set arg [lindex $arg 0]

  # check for input.
  if {[string length [string trim $arg]] == 0 || [qstat:input_check $arg]} {
    putquick "NOTICE $nick :Syntax: $lastbind <ip/host>"
    return 0
  }

  # figure out which command was used.
  switch [string tolower $lastbind] {
    "!hl"     { set gametype "-hls";  set players 0 }
    "!cs"     { set gametype "-hls";  set players 0 }
    "!ut"     { set gametype "-uns";  set players 0 }
    "!qw"     { set gametype "-qws";  set players 0 }
    "!q1"     { set gametype "-qs";   set players 0 }
    "!q2"     { set gametype "-q2s";  set players 0 }
    "!q3"     { set gametype "-q3s";  set players 0 }
    "!rcw"    { set gametype "-rwm";  set players 0 }
    "!bf"     { set gametype "-gps";  set players 0 }
    "!gs"     { set gametype "-gps";  set players 0 }
    "!ut2k3"  { set gametype "-ut2s"; set players 0 }
    "!ut2003" { set gametype "-ut2s"; set players 0 }
    "!hlp"     { set gametype "-hls";  set players 1 }
    "!utp"     { set gametype "-uns";  set players 1 }
    "!qwp"     { set gametype "-qws";  set players 1 }
    "!q1p"     { set gametype "-qs";   set players 1 }
    "!q2p"     { set gametype "-q2s";  set players 1 }
    "!q3p"     { set gametype "-q3s";  set players 1 }
    "!rcwp"    { set gametype "-rwm";  set players 1 }
    "!bfp"     { set gametype "-gps";  set players 1 }
    "!ut2k3p"  { set gametype "-ut2s"; set players 1 }
    "!ut2003p" { set gametype "-ut2s"; set players 1 }
    default {
      putquick "NOTICE $nick :Unknown command."
      return 0
    }
  }

  # run the qstat program.
  if {$players} { 
    set stat [open "|$pathqstat/qstat -timeout 5 $gametype $arg -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
  } else {
    set stat [open "|$pathqstat/qstat -timeout 5 $gametype $arg -Ts $pathqstat/server.qstat" r]
  }

  # output the result.
  qstat:results $chan $nick $stat

  # close fork, end program.
  close $stat
  return 0
}

# show results.
proc qstat:results {chan nick pf} {
  while {[gets $pf line] >= 0} { 
    if {[string match "DOWN*" $line]} {
      putquick "NOTICE $nick :Connection refused while querying server."
      break
    } elseif {[string match "HOSTNOTFOUND*" $line]} {
      putquick "NOTICE $nick :Host not found."
      break
    } elseif {[string match "TIMEOUT*" $line]} {
      putquick "NOTICE $nick :Timeout while querying server."
      break
    }
    putquick "PRIVMSG $chan :$line"  
  }
}

# check for valid chars
proc qstat:input_check {text} {
  if {[regexp \[^\[:alnum:\]_\.\:\] $text]} { return 1 }
  if {[string match "0*" $text]} { return 1 }
  return 0
}

putlog "Qstat4Eggdrop version $qversion: Loaded!"
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

poorly written pipeline handler - blocking, and not checking properly for errors

instead, it should be non-blocking and checking the condition of the pipe with [eof]
F
FuE-
Halfop
Posts: 57
Joined: Sat Nov 27, 2004 3:46 pm

Post by FuE- »

cold you say it in more 'begginer' way :)
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

I can give a very simply answer:
TCL executable calls are currently not working in Eggdrop on Cygwin.
I have an unreplied open question on the windrop page relating to this issue:
https://sourceforge.net/forum/forum.php ... _id=131915

PS: [exec bla] and [open |bla] do the same in the end, so it doesnt matter. At least I get the same error in both syntax variants.
PPS: set pathqstat "C:/SL/scripts/srv/qstat/" + $pathqstat/qstat -> C:/SL/scripts/srv/qstat//qstat
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...
F
FuE-
Halfop
Posts: 57
Joined: Sat Nov 27, 2004 3:46 pm

Post by FuE- »

tnx :)
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

De Kus wrote:I can give a very simply answer:
TCL executable calls are currently not working in Eggdrop on Cygwin.
I have an unreplied open question on the windrop page relating to this issue:
https://sourceforge.net/forum/forum.php ... _id=131915
hmm thats odd

have you tried exec from tclsh under CYGWIN?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

tclsh84:

Code: Select all

% exec bash.exe -c "whois t-online.de"
% Copyright (c)2004 by DENIC
% Version: 1.00.0
%
% Restricted rights.
...
% open "|bash.exe -c \"whois t-online.de\""
file100bb7e8
partyline:

Code: Select all

tcl: evaluate (.tcl): exec bash.exe -c "whois t-online.de"
Tcl error: couldn't duplicate input handle: bad file number
tcl: evaluate (.tcl): open "|bash.exe -c \"whois t-online.de\""
Tcl error: couldn't duplicate input handle: bad file number
I haven't... but you can see the result. It's simply but plain: [exec ...] and [open |...] can't be used with eggdrop under Cygwin. If you can tell me a TCL/eggdrop version combination which works, I am sure many Cygwin users will be 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...
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Your problem may be solved by getting hold of the Window ports of the missing *nix commands in Cygwin. Cygwin comes only with the basic set.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

tell us some that might be missing, but Cygwin has already many *nix commands. It's quiet faszinating how much they can emulate Unix on Windows. Still I can't compile TCL directly with Cygwin, okay, but I can't with MinGW, either, even it should be possible :D. If I could, I would try tcl8.4.9, but I am (we are) stuck with 8.4.7 (I don't know how the package from windrop page is compiled, but the one from tcl.tk is not working for me) :(.

PS: just updated to newst coreutils for cygwin and recompiled v1.6.18+notesfix from scratch (make distclean), same ^-^. just to make it clear, if I try to execute a file that doesn't exist, I will get a file not found error even within eggdrop ;).
If I didn't encounter problems with removing bans in 1.7, I would verify it there as well.
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 »

you should report this also to TCL support mailing list(s), since windrop folks won't answer
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Hmmm.. I've yet to have a problem compiling a Windrop under Cygwin. You will encounter errors if not all the dependencies are installed (this also applies to Linux). Read the error output (not the last message but the first error encountered) and you might be able to determine what's missing. :)

One command missing from Cygwin that comes immediately to mind is "uptime".

For a FULL list of Linux commands see the Alphabetical Directory of Linux Commands and you'll see how much is missing. :wink:
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Alchera wrote:Hmmm.. I've yet to have a problem compiling a Windrop under Cygwin. You will encounter errors if not all the dependencies are installed (this also applies to Linux). Read the error output (not the last message but the first error encountered) and you might be able to determine what's missing. :)

One command missing from Cygwin that comes immediately to mind is "uptime".

For a FULL list of Linux commands see the Alphabetical Directory of Linux Commands and you'll see how much is missing. :wink:
yeah a full list of commands... some I have never heared about and some that a cleary not meant to be installed like mail feature ^^, never I need (and I doubt eggdrop/tcl needs) text editors like vi (I am really satisfied with UltraEdit32 :D). of course there are never DNS servers installed never quota/ssh/ssl/ip(chains|table) features @_o. So its quite difficult to find a command that might help. But from the error I think it might be a way in eggdrop the file is opened. perhaps in *nix you can open a file to read/execute at the same time, but Win NT prevents this. I don't know, but I rather think its something like this than its a missing command :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...
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Your problems compiling the eggdrop source is a missing dependency and not, as you so rightly stated, a missing command (I misread the post). I use tcl/tk 8.4.7 myself and haven't bothered with getting the 8.4.9 tarball as yet.

Check and see if you have these installed: gcc-mingw, mingw-runtime, minires-devel and the latest glib/glib2.

I use NT 5.1 (XP Pro) and initially had to do a bit of fiddling with the Cygwin setup before I could compile the eggdrop source error free.

PS: With some scripts that do use *nix commands it's possible to get hold of the Window ports and just place them in the windrop folder; the scripts then work usually without a drama. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
s
sniegas
Voice
Posts: 1
Joined: Thu Aug 24, 2006 5:38 pm

Post by sniegas »

for me it happened even stranger thing:

Code: Select all

00:40 <@SNow> !cs
00:41 -allstats(~allstats@help.iti.lt)- 1:
00:41 -allstats(~allstats@help.iti.lt)- 2:
00:41 -allstats(~allstats@help.iti.lt)- 3:
00:41 -allstats(~allstats@help.iti.lt)- 4:
00:41 -allstats(~allstats@help.iti.lt)- 5: TIMEOUT (193.219.1.131:27015), /
          players, ,  ms
00:41 -allstats(~allstats@help.iti.lt)- 6: This Server By OMONAS !!!
          (193.219.1.235:27015), 21/23 players, fy_pool_day, 12 ms
00:41 -allstats(~allstats@help.iti.lt)- 7: This server BY OMONAS !!!
          (193.219.1.232:27015), 1/26 players, cs_deagle5, 5 ms
00:41 -allstats(~allstats@help.iti.lt)- 8: cs.sniegas.lt CSDM #sniegas.lt
          server by SNow (84.240.23.4:27015), 19/26 players, de_nuke, 23 ms
the thing is that in the qstat4eggdrop.lst I have only 4 entries:

Code: Select all

debian:/home/stats/.eggdrop# cat qstat4eggdrop.lst
a2s cs.iti.lt
a2s cs.alus.lt
a2s cs.sniegas.lt
a2s cs.police.lt
debian:/home/stats/.eggdrop#
Post Reply