From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 18-MAR-1992 21:36:05.92
To:	ARISIA::EVERHART
CC:	
Subj:	Automatically receive new DSNlink articles

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.123)
	 id AA07026; Wed, 18 Mar 92 21:02:45 EST
Received: From VAXF.COLORADO.EDU by CRVAX.SRI.COM with TCP; Wed, 18 MAR 92 16:15:46 PST
Received: from DECNET-MAIL (PKUERBIS@_CCNODE) by VAXF.COLORADO.EDU (PMDF
 #13006) id <01GHS8XIR9SW000MUZ@VAXF.COLORADO.EDU>; Wed,
 18 Mar 1992 09:16:47 MST
Date: 18 Mar 92 09:16:46 -0700 (MST)
From: Dan Wing <DWING@UH01.Colorado.EDU>
Subject: Automatically receive new DSNlink articles
To: INFO-VAX@SRI.COM
Message-Id: <01GHS8XIRJG2000MUZ@VAXF.COLORADO.EDU>
X-Envelope-To: INFO-VAX@SRI.COM
X-Vms-To: $INFOVAX
Mime-Version: 1.0
Content-Transfer-Encoding: 7BIT

The following COM file will allow you to easily get a list of all new DSNlink
articles.  This can be modified to be submitted daily, weekly, or whenever
you'd like to receive a list of new DSNlink articles.

The original idea for this code was taken from a DSNlink article.

-Dan Wing, DWING@UH01.Colorado.EDU  (or WING_D@UCOLMCC.BITNET)
 Systems Programmer, University Hospital, Denver

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 18-MAR-1992 09:06:26.57   By user DWING (DWING@UH01.Colorado.EDU)
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. DSNLINK_NEW.COM;2
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X$ DSNLINK_NEW$VERSION := 006
X$
X$!  DSNLINK_NEW.COM - get list of new DSNlink articles, and mail them
X$!   to a user.
X$!
X$!  Parameters:
X$!     P1 - `5Boptional`5D  maximum retry count.  DEFAULT = 5
X$!     P2 - `5Boptional`5D  username to send mail to.  DEFAULT = current use
Vr
X$!     P3 - `5Boptional`5D  Since criteria.  Default = YESTERDAY
X$!     P4 - `5Boptional`5D  databases to search.  DEFAULT = list of default`
V20
X$!                      databases are used (see code below)
X$!
X$!
X$!  Idea for this code taken from DSNlink article "`5BDSNlink`5D V1.n How To
V Get`20
X$!  Daily List of New Database Articles"
X$!
X$!
X$!  Copyright `A9 1991-1992 by University Hospital, Denver.
X$!  This code may be freely distributed and modified for non-commercial`20
X$!  purposes.
X$!
X$!  Written by Dan Wing, Systems Programmer, University Hospital, Denver.
X$!  DWING@UH01.Colorado.EDU
X$!
X$!
X$!  REVERSE CHRONOLOGICAL MODIFICATION HISTORY
X$!
X$!  VERSION   EDIT DATE  EDIT  BY   DESCRIPTION
X$!  --------  ---------  ----  ---  ---------------------------------------
X$!   V5.5      2-FEB-92  006   DGW  Use RESTART_VALUE to indicate how many`2
V0
X$!                                  retries have been done.
X$!   V5.5     27-JAN-92  005   DGW  If interactive, prompt for all parameter
Vs,
X$!                                  and allow user to submit to batch.
X$!   V5.5     17-JAN-92  004   DGW  Retry limit = 5
X$!   V5.4-3    5-JAN-92  003   DGW  The "NO" after the "DSN ITS" must be the
Vre
X$!                                  in case DSNlink enters its question-mode
V.
X$!                                  DSNlink was returning "Your response is`
V20
X$!                                  ambiguous. Please re-enter" if the "NO"
X$!                                  was in the DSN$ITS_INIT file.
X$!   V5.4-3    4-JAN-92  002   DGW  Add check for "%DSN-E-" errors as well
X$!                                  as "%DSN-F-" errors to decide to retry.
X$!   V5.4-3   31-DEC-91  001   DGW  Created.
X$! `20
X$!
X$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X$
X$  ON WARNING THEN GOTO _ERROR
X$  ON CONTROL_Y THEN GOTO _ABORT
X$
X$  SET SYMBOL/SCOPE=(noLOCAL,noGLOBAL)
X$
X$  WRITE SYS$OUTPUT ""
X$  WRITE SYS$OUTPUT "DSNLINK_NEW.COM  v", DSNLINK_NEW$VERSION
X$  WRITE SYS$OUTPUT "  Get list of new DSNlink articles."
X$  WRITE SYS$OUTPUT ""
X$
X$!!!
X$
X$  DSN_RETRY_DEFAULT = 5
X$  MAIL_USER_DEFAULT =  F$EDIT(F$GETJPI(0,"USERNAME"),"TRIM")
X$  DSN_SINCE_DEFAULT = "YESTERDAY"
X$  DSN_DATABASES_DEFAULT =  "vms,lat-decserver,cobol,hsc,shadow,vms-rn-nf-do
Vc,vms-sysmgr-doc,decnet"
X$
X$!!!
X$
X$  TMP_DIRFILE = "SYS$LOGIN:DSNLINK_NEW_1_" + F$GETJPI(0,"PID") + ".TMP"
X$  TMP_ERRORFILE = "SYS$LOGIN:DSNLINK_NEW_2_" + F$GETJPI(0,"PID") + ".TMP"
X$  TMP_DSNFILE = "SYS$LOGIN:DSNLINK_NEW_3_" + F$GETJPI(0,"PID") + ".TMP"
X$  INTERACTIVE = F$MODE() .EQS. "INTERACTIVE"
X$  ASK := READ SYS$COMMAND/END_OF_FILE=_ABORT/PROMPT=
X$
X$  IF P1 .EQS. "?" THEN GOTO _HELP
X$
X$  IF P1 .EQS. ""
X$  THEN`20
X$    IF INTERACTIVE THEN ASK "* How many retries? `5B''DSN_RETRY_DEFAULT'`5D
V " P1
X$    IF P1 .EQS. "" THEN P1 = DSN_RETRY_DEFAULT
X$  ENDIF
X$  DSN_RETRY_MAX = P1
X$
X$  IF P2 .EQS. ""
X$  THEN
X$    IF INTERACTIVE THEN ASK "* Send mail to? `5B''MAIL_USER_DEFAULT'`5D " P
V2
X$    P2 = F$EDIT(P2,"UPCASE,COLLAPSE")
X$    IF P2 .EQS. "" THEN P2 = MAIL_USER_DEFAULT
X$  ENDIF
X$  MAIL_USER = P2
X$   `20
X$  IF P3 .EQS. ""
X$  THEN
X$    IF INTERACTIVE THEN ASK "* /SINCE=value? `5BYESTERDAY`5D " P3
X$    P3 = F$EDIT(P3,"UPCASE,COLLAPSE")
X$    IF P3 .EQS. "" THEN P3 = DSN_SINCE_DEFAULT
X$  ENDIF
X$  DSN_SINCE = P3
X$
X$  IF P4 .EQS. ""
X$  THEN
X$    IF INTERACTIVE
X$    THEN
X$      WRITE SYS$OUTPUT "* Databases? (prefix response with + to add databas
Ves to this list)"
X$      ASK "  `5B''DSN_DATABASES_DEFAULT'`5D " P4
X$    ENDIF
X$    IF P4 .EQS. "" THEN P4 = DSN_DATABASES_DEFAULT
X$  ENDIF
X$  IF F$LOCATE("+",P4) .NE. F$LENGTH(P4) THEN P4 = -
X     F$EDIT(F$ELEMENT(1,"+",P4),"UPCASE,COLLAPSE") + "," + DSN_DATABASES_DEF
VAULT
X$  DSN_DATABASES = P4
X$
X$!
X$
X$  WRITE SYS$OUTPUT ""
X$  WRITE SYS$OUTPUT "Mailing all articles since ", P3, " in databases:"
X$  WRITE SYS$OUTPUT P4
X$  WRITE SYS$OUTPUT "to user ", P2, ", with ", P1, " DSNlink connection atte
Vmpts."
X$  WRITE SYS$OUTPUT ""
X$
X$!
X$
X$  IF INTERACTIVE
X$  THEN
X$    ASK "Submit to batch? `5BY`5D " RUN_BATCH
X$    IF RUN_BATCH .OR. RUN_BATCH .EQS. ""
X$    THEN
X$      SUBMIT -
X     /NOTIFY -
X     /QUEUE=DSN$BATCH -
X     /noPRINTER -
X     /PARA=("''P1'","''P2'","''P3'","''P4'") -
X     'F$ENVIRONMENT("PROCEDURE")'
X$      GOTO _EXIT
X$    ENDIF
X$  ENDIF  ! interactive
X$
X$!!!!!
X$
X$  WEEKDAY = F$CVTIME(,,"WEEKDAY")
X$
X$  GOSUB _CLEAN_TMP_FILES
X$ `20
X$
X$  IF F$TRNLNM("DSN$COMMUNICATIONS_DEVICE") .NES. ""
X$  THEN
X$    IF F$GETDVI("DSN$COMMUNICATIONS_DEVICE","PID") .NES. ""
X$    THEN
X$
X$      OPEN/WRITE OUTFILE 'TMP_DSNFILE'
X$      WRITE OUTFILE "open ", DSN_DATABASES
X$      WRITE OUTFILE "dir/all/since=", DSN_SINCE
X$      WRITE OUTFILE "extract/dir ", TMP_DIRFILE
X$      WRITE OUTFILE "exit"
X$      CLOSE OUTFILE
X$
X$      DSN_RETRY_COUNT = 0
X$
X$_DSN_RETRY:
X$      WRITE SYS$OUTPUT "%DSNLINK_NEW-I-ATTCONN, Attempting connection at ",
V F$TIME()
X$      IF F$SEARCH(TMP_ERRORFILE) .NES. "" THEN DELETE 'TMP_ERRORFILE';*
X$
X$      DEFINE DSN$ITS_INIT 'TMP_DSNFILE'
X$      DEFINE SYS$ERROR 'TMP_ERRORFILE'
X$
X$! The "NO" is in case DSNlink enters its question-mode.  See edit 003.
X$
X$      SET noON
X$      DSN ITS
XNO
X$      SET ON
X$
X$      DEASSIGN SYS$ERROR
X$      DEASSIGN DSN$ITS_INIT
X$
X$      IF F$SEARCH(TMP_DIRFILE) .NES. ""
X$      THEN`20
X$        OPEN/APPEND OUTFILE 'TMP_DIRFILE'
X$        WRITE OUTFILE ""
X$        WRITE OUTFILE "The above listing was created from:"
X$        WRITE OUTFILE " Database = ", DSN_DATABASES
X$        WRITE OUTFILE " Since =    ", DSN_SINCE
X$        WRITE OUTFILE ""
X$        WRITE OUTFILE "This mail message sent by code within DSNLINK_NEW.CO
VM"
X$        CLOSE OUTFILE
X$        MAIL 'TMP_DIRFILE' 'MAIL_USER' -
X     /SUBJECT="New DSNlink articles on ''WEEKDAY'" -
X     /PERSONAL="DSNlink articles (retry= ''DSN_RETRY_COUNT')"
X$      ELSE
X$        SEARCH 'TMP_ERRORFILE' "%DSN-F-","%DSN-E-" /EXACT/MATCH=OR
X$        IF $STATUS .EQ. %X00000001
X$        THEN       ! some sort of DSNlink failure
X$          DSN_RETRY_COUNT = DSN_RETRY_COUNT + 1
X$          SET RESTART_VALUE = "Retry count = ''DSN_RETRY_COUNT'"
X$          WRITE SYS$OUTPUT ""
X$          IF DSN_RETRY_COUNT .LT. DSN_RETRY_MAX`20
X$          THEN`20
X$            WRITE SYS$OUTPUT "%DSNLINK_NEW-W-RETRY, Retrying connection in
V 30 secs. (retry # ", DSN_RETRY_COUNT, ")"
X$            WAIT 00:00:30
X$            GOTO _DSN_RETRY
X$          ELSE
X$            WRITE SYS$OUTPUT "%DSNLINK_NEW-E-RETRYLIM, Exceeded maximum ret
Vry limit"
X$          ENDIF
X$        ENDIF ! failed to establish connection
X$        PERSONAL_MESSAGE = F$FAO("NO DSNlink articles (!UL !1%CRetry!%ERetr
Vies!%F)",DSN_RETRY_COUNT)
X$        OPEN/APPEND OUTFILE 'TMP_ERRORFILE'
X$        IF DSN_RETRY_COUNT .LT. DSN_RETRY_MAX
X$        THEN`20
X$          WRITE OUTFILE ""
X$          WRITE OUTFILE "The above listing was created from:"
X$          WRITE OUTFILE " Database = ", DSN_DATABASES
X$          WRITE OUTFILE " Since =    ", DSN_SINCE
X$        ENDIF
X$        WRITE OUTFILE ""
X$        WRITE OUTFILE "This mail message sent by code within DSNLINK_NEW.CO
VM"
X$        CLOSE OUTFILE
X$        MAIL 'TMP_ERRORFILE' 'MAIL_USER' -
X     /SUBJECT="NO new DSNlink articles on ''WEEKDAY'" -
X     /PERSONAL="''PERSONAL_MESSAGE'"
X$      ENDIF   ! if directory file (TMP_DIRFILE) exists
X$    ELSE
X$      WRITE SYS$OUTPUT "DSNlink was installed, but isn't running now"
X$    ENDIF  ! if PID associated with communications-device
X$  ELSE
X$    WRITE SYS$OUTPUT "DSNlink has never been installed on this node"
X$  ENDIF  ! if DSN$COMMUNICATIONS_DEVICE is a logical
X$
X$_EXIT:
X$  GOSUB _CLEAN_TMP_FILES
X$_EXIT_NOCLEANUP:
X$  EXIT
X$
X$_CLEAN_TMP_FILES:
X$  IF F$TRNLNM("OUTFILE") .NES. "" THEN CLOSE OUTFILE
X$  IF F$SEARCH(TMP_DIRFILE) .NES. "" THEN DELETE 'TMP_DIRFILE';*
X$  IF F$SEARCH(TMP_ERRORFILE) .NES. "" THEN DELETE 'TMP_ERRORFILE';*
X$  IF F$SEARCH(TMP_DSNFILE) .NES. "" THEN DELETE 'TMP_DSNFILE';*
X$  RETURN
X$
X$_ERROR:
X$  WRITE SYS$OUTPUT "Unexpected error occurred in DSNLINK_NEW.COM"
X$  GOTO _EXIT
X$
X$_ABORT:
X$  WRITE SYS$OUTPUT "User aborted DSNLINK_NEW.COM"
X$  GOTO _EXIT
X$
X$_HELP:
X$  TYPE SYS$INPUT:
X
X  DSNLINK_NEW.COM - get list of new DSNlink articles.
X `20
XUsage:
X  @DSNLINK_NEW `5Bretry_count`5D `5Busername`5D `5Bsince-criteria`5D `5Bdata
Vbase-list`5D
X
X     P1 - `5Boptional`5D  maximum retry count.  DEFAULT = 5
X     P2 - `5Boptional`5D  username to send mail to.  DEFAULT = current user
X     P3 - `5Boptional`5D  Since criteria.  Default = YESTERDAY
X     P4 - `5Boptional`5D  databases to search.  DEFAULT = list of default`20
X                      databases are used (see code)
X
X$
X$  GOTO _EXIT_NOCLEANUP
$ CALL UNPACK DSNLINK_NEW.COM;2 346692413
$ v=f$verify(v)
$ EXIT

