From:	RTPARK::RLB  "Bob Boyd 8*565-3627  15-Sep-1988 1701" 15-SEP-1988 17:06
To:	@WATCH_ALPHA,RLB         
Subj:	2nd Try on Part 1 of 3 for WATCH.

Message created @ 15-SEP-1988 17:01:57.30

Put the 3 pieces together, get rid of mail headers, @ the result.

Then @BUILD to create the executable.  

Let me know if you have any problems with it.  

================================ 8< cut here ================================
$!..................... Cut between dotted lines and save ......................
$! VAX/VMS archive file created by VMS_SHAR V-5.01 01-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by RLB
$! on Wednesday 7-SEP-1988 13:39:27.59
$!
$! ATTENTION: To keep each article below 15872 bytes, this program
$! has been transmitted in 3 parts.
$! You should concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 4 files:
$! BUILD.COM WATCH.COM WATCH_V5_P1.MAR WATCH_V5_P2.MAR
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="BUILD.COM"
$ Check_Sum_is=2120286910
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$! this procedure will assemble and build the WATCH image for VMS V5.0
X$ write sys$output "Building WATCH for VMS"
X$! Concatenate the 2 pieces
X$ if f$search("watch_v5.mar;").eqs."" then -
X$`009copy watch_v5_p1.mar+watch_v5_p2.mar watch_v5.mar
X$! Assemble it
X$ write sys$output "Assembling source, please ignore generated warning"
X$ macro watch_v5
X$! Link it into an image
X$ write sys$output "Linking executable image"
X$ link/nodebug/notrace/exec=WATCH watch_v5
X$ write sys$output "Build of WATCH complete"
X$ write sys$output "Use @WATCH.COM to run the image"
$ GoSub Convert_File
$ File_is="WATCH.COM"
$ Check_Sum_is=628827115
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$! Invoke WATCH utility to observer another terminal session.
X$!
X$!  p1-- user, process, or terminal name
X$!
X$!  Note:  This procedure is designed to be placed in the same directory
X$!         as where the WATCH utility is placed.
X$!
X$!  Author:  R.L.Boyd, GE Microelectronics Ctr, 1988, rlb@rtpark.ge.com
X$!
X$ vfl = f$ver(0+f$trnlnm("debug$dcl"))
X$ if f$mode().nes."INTERACTIVE" then $ goto EXIT
X$ if p1.eqs."" then -
X$`009read sys$command/error=EXIT/end=EXIT -
X`009p1/prompt="User/Process/Terminal to watch:  "
X$ user_file = "SYS$LOGIN:WATCH$USER_LIST.TMP"
X$ sess_file = "SYS$LOGIN:WATCH$TERM_LIST.TMP"
X$ tmp_file  = "SYS$LOGIN:WATCH$*.TMP"
X$ if p1.eqs."" then $ goto EXIT
X$ who_am_i = f$environment("procedure")
X$ where_am_i = f$parse(who_am_i,,,"device")+f$parse(who_am_i,,,"directory")
X$ watch = "$"+where_am_i+"watch "
X$ req_privs = "CMKRNL"
X$ save_privs = f$setprv(req_privs)
X$ show user/output='USER_FILE'
X$ search 'USER_FILE' 'p1'/output='SESS_FILE'
X$! read the list of terminals
X$ found_cnt = 0
X$ open/read/error=TERM_NONE terms 'SESS_FILE'
X$TERM_LOOP:
X$ read/end=TERM_END/ERROR=TERM_NONE terms term_rec
X$ user_name = f$edit(f$extract(1,12,term_rec),"trim,compress")
X$ process_name = f$edit(f$extract(13,15,term_rec),"trim")
X$ process_pid = f$edit(f$extract(30,8,term_rec),"trim")
X$ virtual_terminal = f$edit(f$extract(40,13,term_rec),"trim")
X$ physical_terminal = f$edit(f$extract(54,13,term_rec),"trim")
X$ if physical_terminal.eqs."Disconnected" then $ goto TERM_LOOP
X$! see if this is the one they wanted
X$ found_cnt = 1+found_cnt
X$ read sys$command/timeout=30/end=EXIT ans-
X`009/prompt="Watch ''user_name'(''process_name') ? [Y] "
X$ if ans.eqs."" then $ ans = "Y"
X$! if it is not, go back and see if there are any more 
X$ if .not.ans then $ goto TERM_LOOP
X$ define/user sys$input sys$command:
X$ watch 'physical_terminal'
X$TERM_END:
X$ if found_cnt .lt.1 then - 
V$ write sys$output "There are no active interactive sessions that match '",p1,"
X'"
X$EXIT:
X$! Clean up and exit
X$ if f$type(save_privs).nes."" then -
X$ `009if save_privs.nes."" then $ x = f$setprv(save_privs)
X$ if f$trnlnm("terms","lnm$process").nes."" then $ close terms
X$ if f$search(TMP_FILE+";").nes."" then $ delete 'TMP_FILE';*/nolog
X$ exit !'f$ver(vfl)'
X$!
X$TERM_NONE:
X$  Write sys$output "There are no terminals that match """,p1,""""
X$  goto EXIT
X$!Last Modified:   9-AUG-1988 16:40:05.31, By: RLB 
$ GoSub Convert_File
$ Goto Part2
$!..............................................................................
============================= End of Text to Cut =============================


-----------------------------------------------------------------
 Bob Boyd                     Usenet:    rlb@rtpark.ge.com
 GE Microelectronics Ctr.     Internet:  rlb%rtpark.ge.com@mcnc           
 POB 13049, MS 7T3-01         BitNet:    rlb%rtpark.ge.com@relay.cs.net
 RTP, NC 27709-3049           Voice:     (919)549-3627 
 GE DECnet: RTPARK::RLB       GE DIALCOMM:  8*565-3627  PROFS: SSAVRNA,MECRLBT
