From: mdm@stegosaur.cis.ohio-state.edu (Michael Moore)
Subject: A non-motif Metaserver GUI (was Re: Hell Peacock)
Organization: The Ohio State University Dept. of Computer and Info. Science
Date: Thu, 8 Oct 1992 19:20:27 GMT

In article <1992Oct8.174736.27970@cis.uab.edu> patton@phy.uab.edu writes:
>Does anybody know of any code similar to the xnetrekm program at 
>pittslug.sug.org
>which does not require  Motiff ?
>Is there anything similar which works with Metaserver II?
>

	Sure.... I don't have the foggiest idea what ftp server
this script is sitting on, so I'll post it here.  It uses a public
domain toolkit called Tk, which in appearance is similar to Motif.
You need the tcl/tk package to use it.  So here's the steps :

1)  ftp sprite.berkeley.edu and do : cd tcl , binary, get tk2.3.tar.Z.
2)  Check out the README, follow directions for compiling "wish",
	which is the Tk windowing shell (similar to csh but for windows).
3)  Once you have wish, simply save the following script to a file,
	make its permissions executable, and do "wish -f <filename>",
	or if you really know what is going on, change the first line
	of the file to point to your wish binary, and just run the
	script file itself.	

	Please note that this is a bastardized version of the original
script.  I just hacked it up to work with charon's current 3520 port
output.  If someone has a better version, please let me know, so I can
get my grubby paws on it.

	-Michael

----- BEGIN SCRIPT ----

#!/n/monster/0/mdm/bin/wish -f
#

# Thu Jul 23, 2:06 p.m. PDT 1992
#
# This script is modified so that you can use it WITHOUT the
# tclRawTCP extension.  You can obtain tk2.1/tcl6.3 via ftp from
# sprite.berkeley.edu.
#
#               - Jiang Wu (jiangwu@postgres.berkeley.edu)
#


# This Tk program displays the output of the METASERVER program.
# If you double click on the server name a netrek will be started for
# that server.
#
# You will need tk2.1 plus the tclRawTCP extension.  Both packages
# can be found on barkley.berkeley.edu in /tcl directory.  A binary
# for SunOS 4.1 sparcs can be ftp'ed from
# soda.berkeley.edu:/pub/incoming/wish+tclRawTCP.sun4, at least
# for now.
#
# Go ahead and do anything you want with this code.
#
#                     -Sam Shen (sls@aero.org)
#
# $Id: netrekmon.tk,v 1.1 1992/07/14 02:24:22 sls Exp $
#
# $Log: netrekmon.tk,v $
# Revision 1.1  1992/07/14  02:24:22  sls
# Initial revision
#

# Where is the temp directory?
set tmpDir /tmp

# Where is metaserver running?
set server charon.amdahl.com 
set port 3520

# Where can I find the netrek executable?
set netrek /n/monster/0/mdm/bin/udp_netrek

# For servers that lie about what host address to use.  Calvin is
# the only one I know that needs this.
set addressMap(calvin.usc.edu) 128.125.253.129

# Beyond here you shouldn't need to modify anthing.

option add borderwidth 2 interactive

label .info -text "METASERVER @ $server, port $port"
wm minsize . 100 100
wm title . "METASERVER Tk2.1 Interface"

pack append . .info "fill expand"

label .time -relief sunken
pack append . .time "fill expand"

frame .buttons -borderwidth 6
button .buttons.update -text "Update" -command UpdateList
button .buttons.quit -text "Quit" -command exit
pack append .buttons .buttons.update "left fill expand" .buttons.quit "left fill expand"
pack append . .buttons "fill expand"

label .status -width 40 -relief sunken
pack append . .status "fill expand"

proc TripleListView {name args} {
    eval "$name.column1.list yview $args"
    eval "$name.column2.list yview $args"
    eval "$name.column3.list yview $args"
}

proc CreateColumn {name yscroll title geometry} {
        frame $name
        label $name.label -text $title -relief raised
        listbox $name.list -yscroll $yscroll -relief raised -geometry $geometry
        pack append $name $name.label "top fill expand" \
                $name.list "bottom fill expand"
}

proc CreateTripleList {name title1 title2 title3} {
        frame $name -borderwidth 6
        frame $name.column4
        label $name.column4.filler -text ""
        scrollbar $name.column4.scroll -command "TripleListView $name"
        pack append $name.column4 $name.column4.filler "top fillx" \
                $name.column4.scroll "bottom expand fill"
        CreateColumn $name.column1 "$name.column4.scroll set" $title1 30x20
        CreateColumn $name.column2 "$name.column4.scroll set" $title2 12x20
        CreateColumn $name.column3 "$name.column4.scroll set" $title3 10x20
        pack append $name $name.column4 "right filly" \
                $name.column1 "left expand fill" \
                $name.column2 "left expand fill" \
                $name.column3 "left expand fill"
}

CreateTripleList .servers "Servers" "Status" "Time"
bind .servers.column1.list <Double-1> \
        {StartNetrek [.servers.column1.list get \
                        [.servers.column1.list nearest %y]]}
pack append . .servers "fill expand"

proc getline {fileid} {
        set glresult ""
        for {set tempC [read $fileid 1]} \
            {($tempC != "") && ($tempC != "\n")} \
            {set tempC [read $fileid 1]} {
            append glresult $tempC
        }
        return $glresult
}

proc UpdateList {} {
        global n server port tmpDir
        .status config -text "Connecting to $server..."
        update
        catch "exec telnet $server $port > $tmpDir/.serverList"
        set of [open $tmpDir/.serverList]

        set readingServers 0
        set n 0
        .servers.column1.list delete 0 end
        .servers.column2.list delete 0 end
        .servers.column3.list delete 0 end

        while {[eof $of] == 0} {
                set line [getline $of]
                if {[string first "Server Check period:" $line] == 0} {
                        set readingServers 1
                        continue
                }
                if {$readingServers == 0} {
                        continue
                }
                if {[string trim $line] == ""} {
                        set readingServers 0
                        continue
                }
                set splitline [split $line ":"]
                .servers.column1.list insert end \
                        [string trim [lindex $splitline 0]]
                .servers.column2.list insert end \
                        [ParsePlayers [string trim [lindex $splitline 1]]]
                .servers.column3.list insert end \
                        [lindex $line [expr {[llength $line]-1}]]
                incr n
        }
        close $of
        exec rm -f $tmpDir/.serverList

        .status config -text "Read $n servers."
        .time config -text "Last update at: [exec date]"
}

proc ParsePlayers {players} {
        if {[string first "Wait Queue" $players] == 0} {
                return "wait queue: [lindex $players 2]"
        }
        if {[string first "Couldn't connect" $players] == 0} {
                return "down"
        }
        return "players: [lindex $players 0]"
}

proc StartNetrek {server} {
        global netrek addressMap env
        set tmp [split $server "()"]
        set server [lindex $tmp 0]
        set port [lindex $tmp 1]
        if {[info exists addressMap($server)] == 1} {
                set server $addressMap($server)
        }
#	scan [time who] %d xx
	set display $env(DISPLAY)
        set host $env(HOST)
        .status config -text "Attempting to connect to $server."
        exec $netrek -h $server -p $port -d $display &
}

-------------- END SCRIPT ----------------
-- 
 ---------------------------------------------------------------------
|Michael Delbert Moore              \  "Our lives for the most part   |
|OSU Student Programmer              \  are made up of little things, |
|Undergraduate CIS Major             /  and by these our character is |
Organization: Carnegie Mellon, Pittsburgh, PA