carl@CITHEX.CALTECH.EDU (07/07/88)
The DCL procedure that follows is a simple implementation of a DECnet object
to give information about users on a DECnet node. It uses a data file (in
the case of CITHEX, HEP$UTIL:USERS.KEY) with the following FDL description:
!*******************************************************************************
FILE
ORGANIZATION indexed
RECORD
FORMAT FIXED
SIZE 44
KEY 0
NAME "Real Name"
SEG0_LENGTH 32
SEG0_POSITION 0
TYPE string
KEY 1
NAME "USERNAME"
SEG0_LENGTH 12
SEG0_POSITION 32
TYPE string
!*******************************************************************************
When invoked from a non-network process, it prompts for input of:
1) A specification as to the direction of translation desired, either
USERNAME-TO-NAME or NAME-TO-USERNAME
2) The name to be translated. The name is treated as an abbreviation
and is mapped to uppercase, i.e., if "ca" is specified on CITHEX,
it matches both
CAPELL, MIKE CAPELL
and
CARMINATI, FEDERICO CARMINATI
If no name is specified, all records in the database are output.
3) The node to be interrogated. If no node is specified, the current
node (0) is used.
and outputs a list of all matching records to SYS$OUTPUT. When invoked
by a network process, it reads SYS$NET: for a record of the form
USER_TO_NAME name
or
NAME_TO_USER name
If the record isn't of this form, it writes instructions on usage to SYS$NET:,
closes the file and exits. If the record is syntactically correct, it outputs
all matching records to SYS$NET:, closes the file, and exits. The program
currently allows only one inquiry per network session, but that could be
fairly easily changed. The program was written in response to a request
from SLACVM for names of the users on CITHEX to be used in a database they've
set up. I thought I might as well set up something similar but accessible
to systems on HEPnet/SPAN that don't have access to SLACVM. Your recent
posting about such servers prompted me to dig it up and document it a bit.
On CITHEX, it's installed as DECnet object USERINFO, as follows:
Object Permanent Characteristics as of 6-JUL-1988 20:20:03
Object = USERINFO
Number = 0
File id = HEP$UTIL:USERINFO.COM
You should be able to extract the procedure and run it as-is on your machine if
you want to try it out, though thus far, CITHEX is the only machine with
this DECnet object installed, as far as I know.
$!******************************************************************************
$! USERINFO.COM - Map username to real name
$! THE COMMAND AFTER THE RECORD FLAGGED "$!####" SHOULD BY CHANGED
$! TO SUIT YOUR SITE
$ IF F$MODE() .EQS. "NETWORK" THEN GOTO SERV
$ ON WARNING THEN GOTO CLOS
$ ON CONTROL_Y THEN GOTO CLOS
$ CMD :=
$ TRAN: READ/PROMPT="USER-TO-NAME OR NAME-TO-USER TRANSLATION [U/N]: " -
SYS$COMMAND REC
$ REC = F$EDIT(F$EXTRACT(0,1,REC),"UPCASE")
$ IF REC .EQS. "U" THEN CMD = "USER_TO_NAME"
$ IF REC .EQS. "N" THEN CMD = "NAME_TO_USER"
$ IF CMD .NES. "" THEN GOTO KEY
$ WRITE SYS$COMMAND "PLEASE RESPOND WITH EITHER ""U"" OR ""N"""
$ GOTO TRAN
$ KEY: READ/PROMPT="Name: " SYS$COMMAND REC
$ CMD = CMD + " " + F$EDIT(REC,"UPCASE")
$ READ/PROMPT="Node: " SYS$COMMAND REC
$ IF REC .EQS. "" THEN REC = "0"
$ OPEN/READ/WRITE NETWORK_FILE 'REC'::"TASK=USERINFO"
$ WRITE NETWORK_FILE CMD
$ COPY NETWORK_FILE SYS$OUTPUT
$ CLOS: CLOSE NETWORK_FILE
$ EXIT
$ SERV: OPEN/READ/WRITE NETWORK_FILE SYS$NET:
$ READ NETWORK_FILE COMMAND
$ COMMAND = F$EDIT(COMMAND,UPCASE)
$ IF F$ELEMENT(0," ",COMMAND) .EQS. "USER_TO_NAME" THEN GOTO USER
$ IF F$ELEMENT(0," ",COMMAND) .EQS. "NAME_TO_USER" THEN GOTO NAME
$ WRITE NETWORK_FILE
$ S1 = "Valid commands are"
$ S2 = "USER_TO_NAME username"
$ S3 = "NAME_TO_USER realname"
$ S = F$FAO("!AS!/!_!AS!/!_!AS", S1, S2, S3)
$ WRITE NETWORK_FILE S
$ CLOSE NETWORK_FILE
$ EXIT
$ USER: KEY = F$EXTRACT(0,12,F$ELEMENT(1," ",COMMAND+" ")+F$FAO("!12* "))
$ INDEX = 1
$ OFFSET = 32
$ GOTO LIST
$ NAME: KEY = F$EXTRACT(0,32,F$ELEMENT(1," ",COMMAND+" ")+F$FAO("!32* "))
$ INDEX = 0
$ OFFSET = 0
$ LIST: VAL = F$ELEMENT(0," ", KEY)
$ LEN = F$LENGTH(VAL)
$ NREC = 0
$!#### CHANGE THE FILESPEC IN THE FOLLOWING COMMAND TO SUIT YOUR SITE
$ OPEN/READ/SHARE=WRITE USER_FILE HEP$UTIL:USERS.KEY
$ READ/MATCH=GE/KEY="''KEY'"/INDEX='INDEX'/ERR=DONE USER_FILE RECORD
$ LOOP: IF F$EXTRACT(OFFSET,LEN,RECORD) .NES. VAL THEN GOTO DONE
$ NREC = NREC + 1
$ WRITE NETWORK_FILE RECORD
$ READ/ERR=DONE USER_FILE RECORD
$ GOTO LOOP
$ DONE: CLOSE USER_FILE
$ IF NREC .EQ. 0 THEN -
$ WRITE NETWORK_FILE "NO MATCHES"
$ CLOSE NETWORK_FILE
$!******************************************************************************