From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 18-JAN-1989 19:10
To:	MRGATE::"ARISIA::EVERHART"
Subj:	This .COM shows LAT server and port names


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 18 JAN 89 14:55:29 PDT
Received: from hqhsd.brooks.af.mil by KL.SRI.COM with TCP; Wed, 18 Jan 89 14:41:11 PST
Date: 18 Jan 89 16:14:00 CST
From: "HSDP2::WILSONJL" <wilsonjl%hsdp2.decnet@hqhsd.brooks.af.mil>
Subject: This .COM shows LAT server and port names
To: "info-vax" <info-vax@kl.sri.com>

                             
Hi netters,

The following DCL hack does what Chris Markis requested - essentially a SHOW
USERS that displays LAT server and port. Please, no flames, I know it's a nasty
but it gets the job done and was quick to write. I use it on a VMS 4.7 cluster,
but it works on 5.0-2 as well. It could be rewritten as a faster hack in
version 5 though (this is left as an exercise for the reader :-)

This is a single-part (!) VMS_SHARE module. 

Jonathan L Wilson 
TRW Defense Systems Group 
MILNET: WILSONJL@HQHSD.BROOKS.AF.MIL 
Phone:  (512) 536 2236   
Standard disclaimer applies.
 
                 "Who says brute force programming is dead?"
                 

$! ...................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user WILSONJL
$! on 18-JAN-1989 16:03:44.13.
$!
$! It contains the following 1 file:
$!        SHOW_PORTS.COM
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.03 20-Oct-1988 requires VMS V4.4 or higher."
$ EXIT 44 
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY

b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) );
s_file_spec := GET_INFO( COMMAND_LINE, "output_file" );SET( OUTPUT_FILE
, b_part, s_file_spec ); 
b_errors := CREATE_BUFFER( "{Errors}" );i_errors := 0; 
pat_beg_1 := ANCHOR & "-+-+-+ Beginning";
pat_beg_2 := LINE_BEGIN & "+-+-+-+ Beginning";
pat_end := ANCHOR & "+-+-+-+-+ End";
pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b 
:= SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) )
; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER
( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; ENDLOOP; POSITION( BEGINNING_OF
( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE ) = END_OF( b_part )
; s_x := ERASE_CHARACTER( 1 ); 
  IF s_x = "+" THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF; 
  IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF; 
  IF s_x = "V" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x = "X" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x <> "" THEN i_errors := i_errors + 1; s_text := CURRENT_LINE; POSITION
( b_errors ); 
    COPY_TEXT( "The following line could not be unpacked properly:" )
; SPLIT_LINE; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part )
; MOVE_VERTICAL( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP 
  r_x := SEARCH( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x )
; ERASE_CHARACTER( 1 ); 
  IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) ); 
  COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; 
  SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" );ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "SHOW_PORTS.COM"
$ CHECKSUM_IS = 845959180
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$! SHOW_PORTS.COM - show LAT port associations for users
X$!
X$! Quick 'n dirty by Jon Wilson / TRW, 5-Oct-1988
X$! Author is WILSONJL@HQHSD.BROOKS.AF.MIL (Milnet)
X$!
X$`009LATCP :== $LATCP
X$`009if .not. f$privilege("CMKRNL") then goto NO_PRIV
X$`009on error then goto LOOP_END
X$`009on control_y then goto LOOP_END
X$`009show users/output=sys$scratch:show_ports.ctl
X$`009open/read infile sys$scratch:show_ports.ctl
X$`009read infile discard
X$`009read infile discard
X$`009read infile discard
X$`009write sys$output ""
X$`009write sys$output "      SHOW USERS with LAT Ports"`032
X$`009write sys$output ""
X$`009write sys$output " Username    Terminal   Server   Port"
X$LOOP_TOP:
X$`009nodename = ""
X$`009port = ""
X$`009read/end=LOOP_END infile record
X$`009username = f$edit(f$extract(0,13,record),"TRIM")
X$`009record = f$edit(f$extract(40,255,record),"COMPRESS,TRIM")
X$`009terminal = f$element(0,":",record)
X$`009if terminal .eqs. ":" then goto ERROR
X$`009terminal = f$extract(0,7,terminal)
X$`009terminal = "''terminal':"
X$`009on error then goto LOOP_END
X$`009on control_y then goto LOOP_END
X$`009if f$locate("LTA",terminal) .nes. f$length(terminal) then -
X`009`009gosub CALL_LAT
X$`009on error then goto LOOP_END
X$`009on control_y then goto LOOP_END
X$`009out = f$fao("!12AS  !8AS  !6AS  !12AS",username,terminal,nodename,port)
X$`009write sys$output out
X$`009goto LOOP_TOP   `032
X$LOOP_END:
X$`009write sys$output " "`032
X$`009close infile        `032
X$`009if f$search("sys$scratch:show_ports.ctl") .nes. "" then -
X`009  delete/noconf/nolog sys$scratch:show_ports.ctl;*
X$`009if f$search("sys$scratch:show_ports.tmp") .nes. "" then -
X`009  delete/noconf/nolog sys$scratch:show_ports.tmp;*
X$`009if f$search("sys$scratch:show_ports.dat") .nes. "" then -
X`009  delete/noconf/nolog sys$scratch:show_ports.dat;*
X$`009exit
X$!
X$!-----------------------------------------------------------------------------
X$!
X$CALL_LAT:
X$`009on control_y then goto LOGGED_OUT
X$`009open/write outfile sys$scratch:show_ports.tmp
X$`009write outfile "$ ASSIGN/USER_MODE SYS$SCRATCH:SHOW_PORTS.DAT SYS$OUTPUT"
X$`009write outfile "$ LATCP show port ''terminal'"                         `032
X$`009close outfile
X$`009@sys$scratch:show_ports.tmp
X$`009open/read datfile sys$scratch:show_ports.dat
X$`009read datfile discard
X$`009read/end=LOGGED_OUT/err=LOGGED_OUT datfile datrec
X$`009nodename = f$edit(f$element(1,"=",datrec),"TRIM")
X$`009read/end=LOGGED_OUT/err=LOGGED_OUT datfile datrec
X$`009port = f$edit(f$element(1,"=",datrec),"TRIM")    `032
X$LOGGED_OUT:
X$`009close datfile
X$`009if f$search("sys$scratch:show_ports.dat") .nes. "" then -
X`009  delete/noconf/nolog sys$scratch:show_ports.dat;*
X$`009return
X$!
X$!-----------------------------------------------------------------------------
X$!
X$NO_PRIV:
X$`009write sys$output "You do not have the requisite privileges, sorry"
X$`009exit
$ GOSUB UNPACK_FILE
$ EXIT


