[mod.computers.vax] VMS Kermit and DTR

DPVC@UORDBV.BITNET (02/12/86)

I sent this some months ago, but never saw it on the net, so I am trying
to send it again.  Sorry for the delay.

>Date: Thu, 17 Oct 85 21:53:16 edt
>From: faron!sidney@mitre-bedford.ARPA
>Subject: Dropping DTR on VMS
>
>We have the latest VMS Kermit running under VMS 4.whatever, talking to
>an autodial modem through a DMF-32 mux. The only way the VAX can get
>the modem to hang up the phone is by dopping DTR. Can anyone help with
>a way to do that, perhaps with a little program like the one that was
>in the last info-kermit digest for MSDOS? Are there any VMS SET TERM
>parameters that are involved?
>
>                    Sidney Markowitz
>

The /[NO]MODEM qualifier of the SET TERMINAL command is the one you will need
to use.  Going from MODEM to NOMODEM hangs up the line (I have heard, however,
that some DMF-32s do not support modem control properly; we use DZ-11s, here,
and DMF-32 emulators that support modem control).  Unfortunately, KERMIT does
not set the line to MODEM for you so you must remember to do this yourself
whenever you intend to use the CONNECT command.  To do this, make sure the
line is NOMODEM by default (SET TERMINAL/NOMODEM/PERMANENT KER$COMM). When you
wish to use KERMIT, allocate the line (ALLOCATE KER$COMM) and then set it to
MODEM (SET TERMINAL/MODEM KER$COMM) then run KERMIT.  When you are done,
deallocate the line (DEALLOCATE KER$COMM); this will cause the line to revert
to its default state (NOMODEM), which hangs up the line.  Note that, if you
forget to deallocate the line, it is deallocated automatically when you log
off; this is the reason for having NOMODEM the default (that way, the line is
hung up automatically when you log off).

Since people are generally forgetful, it is best to have a command procedure
that handles these details for them.  The following is such a command
procedure, which includes many additional features.  Its main purpose is to
allocate the proper line and set it to MODEM control, but as we have more than
one outgoing line, I included the ability to choice from among any number of
lines (these are identified by the logical names KER$COMM1, KER$COMM2, ...).
In addition, we use KERMIT both as a local kermit (one that use the CONNECT
command), and as a remote (one that usually runs as a SERVER), but we don't
want people to allocate outgoing lines that they don't need.  Furthermore, we
don't want users to have to SET LINE SYS$INPUT when they are using KERMIT as a
remote (they always seem to forget that).  Thus we wanted KERMIT to choose the
line for them, taking into account the expected use of KERMIT (local or remote),
the availability of any of a number of lines, and the posibility that the user
already has one of these lines in use (pre-allocated).  The command procedure
that follows performs these functions.

This procedure also sets up (temporarily) the logical name SYS$NODE if it's
not defined (VMS KERMIT uses this when it reports its connect messages), and
if you use control-C or control-Y to exit from a remote terminal session, it
tells you that you have returned to the local VAX (this is very helpful if the
remote also is a VAX, and you happen to cancel a directory listing of
something; without this warning, it looks like you are still using the remote,
while actually, you have cancelled KERMIT as well, and are back at the local
VAX).

See the instructions in the comments at the top of the procedure for the
definition of the KERMIT symbol.  The comments within the procedure should
explain what actually is happening.  I know it looks ugly in places, and seems
long, but it has quite a bit of work to do, and DEC does not support control
structures in DCL.

IF you are using version 3.x of VMS, then replace line 90 (which uses
the new lexical function F$ELEMENT) by the following three lines

$    qualifiers = F$EXTRACT(1,-1,qualifiers)    ! cut out "/" (so F$LOCATE won't
 find it)
$    pos = F$LOCATE("/",qualifiers)             ! find next qualifer, if any
$    qual = F$EXTRACT(0,pos,qualifiers)         ! save qualifier name

Also, replace F$TRNLNM by F$LOGICAL in lines 145 and 237.

A (short) help file for this new KERMIT command and its qualifiers is included
after the body of the command procedure.

If you have difficulties with this procedure, please feel free to contact me.

                                        Davide P. Cervone

                                        BITNET:  DPVC@UORDBV


=============================== KERMIT.COM ===================================


$ Verify = F$VERIFY(0)
!-----------------------------------------------------------------------------
!
! KERMIT.COM            Version 1.1     12-FEB-1985
!
! PURPOSE:
!       To allocate KER$COMM only when needed, and then SET TERM/MODEM KER$COMM
!       and to choose from among (possibly) many outgoing lines.
!       The user specifies whether the kermit will be used as a Local or
!       Remote kermit.
!
! ENVIRONMENT:
!       Can be run by any user, without requiring privileges.
!       Runs under the VMS operating system, last tested VMS version 4.1
!       Runs LOCAL$EXE:KERMIT.EXE
!       Allocates a terminal line (specified by KER$COMM or KER$COMM#)
!
! SYMBOL DEFINITION:
!       KERMIT :== @KERMIT.COM n
!       where n is the number of KER$COMM# logicals (i.e., the number
!       of out-going lines available).  If n=0, then KER$COMM is used.
!       For instance, if n=2, then KER$COMM1 and KER$COMM2 should point
!       to the two outgoing terminal lines
!
! CALLING SEQUENCE:
!       $ KERMIT [/REMOTE] [/LOCAL] [command]
!       where /LOCAL means KERMIT will use the CONNECT command, and
!       /REMOTE means it won't.  Since this sometimes is confusing,
!       synonimous qualifiers /CONNECT (for /LOCAL) and /NOCONNECT
!       (for /REMOTE) are provided.
!
! REVISION HISTORY:
!     Version      Date             Who                 Project Description
!     -------      ----             ---                 -------------------
!       1.0     12-FEB-1985     Davide P. Cervone       Wrote it
!       1.1     27-FEB-1985     Davide P. Cervone       Added ability to check m
ultiple KER$COMM lines
!       1.1     14-AUG-1985     Davide P. Cervone       Added check for OPA0, si
nce using KERMIT from the operator's
!                                                       terminal crashes the VAX
!       1.1     25-OCT-1985     Davide P. Cervone       Make it a little more ge
neric, so that I can
!                                                       send it for distribution
!
!-----------------------------------------------------------------------------

!
!       Definitions needed to make structured IF statements
!
$ IFF := IF .NOT.
$ DO_TO := GOTO

!
!       Set up defaults, and get input from keyboard
!
$ ON WARNING THEN EXIT          ! EXIT on any error or warning
$ IF "''KER_LINE'" .EQS. "" THEN KER_LINE == ""  ! Set up KER_LINE for storing l
ast used line
$ Kerm = "LOCAL"                ! specifies LOCAL or REMOTE kermit
$ Specified = "FALSE"           ! tells whether a qualifier was used (otherwise
prompt)
$ Allocated = ""                ! holds name of line allocated (to DEALLOCATE)

!
!       Create qualifier list from parameters that start with "/"
!
$ n = 2                         ! specifies what parameter we are using
$ qualifiers = ""               ! start with no qualifiers
$ Loop1:
$ IFF ((F$EXTRACT(0,1,p'n') .EQS. "/") .OR. -
       (F$EXTRACT(F$LENGTH(qualifiers)-1,1,qualifiers) .EQS. "/")) THEN DO_TO En
dLoop1
$    qualifiers = qualifiers + p'n'
$    n = n + 1
$    IF n .LT. 9 THEN GOTO Loop1
$ EndLoop1:

!
!       Create command string from all remaining parameters;
!       this will be passed to KERMIT as a foreign command line
!
$ command = ""
$ Loop2:
$ IF n .GT. 8 THEN GOTO EndLoop2
$    command = command + " " + p'n'
$    n = n + 1
$    GOTO Loop2
$ EndLoop2:

!
!       Check for qualifiers:  /LOCAL or /CONNECT mean allocate line,
!                              /REMOTE or /NOCONNECT mean don't need line
!
!       Abbreviations are allowed; any other qualifier is an error
!
$ Loop3:
$ IFF (F$EXTRACT(0,1,qualifiers) .EQS. "/") THEN DO_TO EndLoop3
$    Specified = "TRUE"                         ! qualifier is present
$    qual = F$ELEMENT(1,"/",qualifiers)         ! get the first qualifier
$    IFF (qual .EQS. "") THEN DO_TO EndIf1      ! will error if no qualifier giv
en
$       WRITE SYS$ERROR "%KERM-E-NOQUAL, no qualifier keyword"
$       WRITE SYS$ERROR "  \\",qualifiers"
$       EXIT
$    EndIf1:
$    qualifiers = qualifiers - "/" - qual       ! remove qual from list
$    IFF ((F$LOCATE(qual,"CONNECT") .EQ. 0) .OR. -
          (F$LOCATE(qual,"LOCAL") .EQ. 0))  THEN DO_TO Else2
$       Kerm = "LOCAL"
$       GOTO EndIf2
$      Else2:
$       IFF ((F$LOCATE(qual,"NOCONNECT") .EQ. 0) .OR. -
             (F$LOCATE(qual,"REMOTE") .EQ. 0))   THEN DO_TO Else3
$          Kerm = "REMOTE"
$          GOTO EndIf3
$         Else3:
$          WRITE SYS$ERROR "%KERM-E-ILQUAL, illegal qualifier keyword"
$          WRITE SYS$ERROR "  \",qual,"\"
$          EXIT
$       EndIf3:
$    EndIf2:
$    IF qualifiers .NES. "" THEN GOTO Loop3
$ EndLoop3:

!
!       If user requests /REMOTE, then we can go right on to running KERMIT
!       (no need to look for lines since the transfer line for remotes
!       is SYS$INPUT)
!
$ IFF (kerm .EQS. "REMOTE") THEN DO_TO EndIf15
$    KER_LINE :== SYS$INPUT
$    GOTO RUN_KERMIT
$ EndIf15:

!
!       Choose which line to use:  if no extra lines (i.e., p1=0) then
!       use KER$COMM; otherwise, if we were using a line before (i.e.,
!       KER_LINE <> "") then check if we still own it, if so use that one
!       (we may have used ^C to get out, leaving KERMIT connected); if not,
!       then look throught the logicals KER$COMMn for lines that we own (use
!       these first) or lines that are free; if none, then KER_LINE="".
!
$ PID = F$GETJPI("","PID")
$ IFF (p1 .LE. 0) THEN DO_TO Else4
$    KER_LINE :== KER$COMM
$    GOTO EndIf4
$   Else4:
$    IF KER_LINE .NES. "" THEN -
$       IF F$GETDVI(KER_LINE,"PID") .NES. PID THEN KER_LINE == ""
!    EndIf:
$    IFF (KER_LINE .EQS. "") THEN DO_TO EndIf5
$       n = p1
$       KER_FREE = ""
$       Loop4:
$          KER_TEST = F$TRNLNM("KER$COMM''n'")
$          IFF (KER_TEST .NES. "") THEN DO_TO EndIf6
$             Line_PID = F$GETDVI(KER_TEST,"PID")
$             IF Line_PID .EQS. PID THEN KER_LINE == KER_TEST
$             IF Line_PID .EQS. ""  THEN KER_FREE =  KER_TEST
$          EndIf6:
$          n = n - 1
$          IF (n .GT. 0) .AND. (KER_LINE .EQS. "") THEN GOTO Loop4
$       EndLoop4:
$       IF KER_LINE .EQS. "" THEN KER_LINE == KER_FREE
$    EndIf5:
$ EndIf4:

!
!       Set KER_LINE to the name of the line and find out whether we can
!       get the line defined by KER_LINE.
!
$ can_get_line = "FALSE"
$ IFF (KER_LINE .NES. "") THEN DO_TO EndIf7
$    KER_LINE == F$GETDVI(KER_LINE,"DEVNAM")
$    Line_PID =  F$GETDVI(KER_LINE,"PID")
$    IF (Line_PID .EQS. PID) .OR. (Line_PID .EQS. "") THEN can_get_line = "TRUE"
$ EndIf7:

!
!       If no qualifer was specified and if KER$COMM is available
!       then find out whether the user needs the line or not;
!
$ IFF ((.NOT. Specified) .AND. can_get_line) THEN DO_TO EndIf8
$    INQUIRE/NOPUNCT qual "Use KERMIT as Local or Remote (L or R) [R]? "
$    Kerm = ""
$    IF F$LOCATE(qual,"LOCAL")  .EQ. 0 THEN Kerm = "LOCAL"
$    IF F$LOCATE(qual,"REMOTE") .EQ. 0 THEN Kerm = "REMOTE"
$    IFF (Kerm .EQS. "") THEN DO_TO EndIf9
$       WRITE SYS$ERROR "%KERM-E-NOTLOR, KERMIT must be LOCAL or REMOTE"
$       EXIT
$    EndIf9:
$ EndIf8:

!
!       If Local Kermit is requested, then find out if the KER$COMM
!       line is allocated or if we can get it;
!       If it is available, allocate it, set it to MODEM, and save the name
!       so that we can deallocate it later.
!       If unavailable, then give an appropriate message, and EXIT if the
!       user requested a LOCAL kermit with a qualifier; if no qualifier
!       was used, then the message is a warning, and the transefer line is
!       set so that KERMIT can be used as a REMOTE.
!
!       If the user specified a REMOTE kermit, there is no need to allocate
!       a line, so KER_LINE is set up for REMOTE use.
!
$ IFF (Kerm .EQS. "LOCAL") THEN DO_TO Else10
$    IFF (KER_LINE .NES. "") THEN DO_TO Else11
$       IFF (can_get_line) THEN DO_TO Else12
$         IFF F$GETJPI("","TERMINAL") .EQS. "OPA0:" THEN DO_TO EndIf14
$            WRITE SYS$ERROR "%KERM-E-NOOPER, operators can't use kermit from OP
A0:"
$            STOP
$         EndIf14:
$         ALLOCATE 'KER_LINE'
$         SET TERMINAL/MODEM 'KER_LINE' ! set other line characteristics here
$         Allocated = KER_LINE
$         GOTO EndIf12
$        ELSE12:
$          WRITE SYS$ERROR "%KERM-E-LINEALL, communication line is allocated to
another user"
$          WRITE SYS$ERROR "             KERMIT can be used only as a REMOTE"
$          IF Specified THEN EXIT
$          KER_LINE := SYS$INPUT
$       EndIf12:
$       GOTO EndIf11
$      ELSE11:
$       WRITE SYS$ERROR "%KERM-E-NOCOMM, no communication line defined"
$       WRITE SYS$ERROR "                KERMIT can be used only as a REMOTE"
$       IF Specified THEN EXIT
$       KER_LINE := SYS$INPUT
$    EndIf11:
$    GOTO Endif10
$   ELSE10:
$    KER_LINE := SYS$INPUT
$ EndIf10:


 Run_Kermit:

!
!       Call SYS$SYSTEM:KERMIT.EXE with the appropriate command line and
!       communication line, and DEALLOCATE KER$COMM if the line was
!       allocated earlier
!
$ ON CONTROL_Y THEN GOTO CTRL_Y_EXIT
$ WRITE SYS$OUTPUT ""
$ KERMIT := $KERMIT.exe
$ node = F$TRNLNM("SYS$NODE")
$ IF node .EQS. "" THEN node = "VAX::"  ! for if DECNET is not running
$ DEFINE/USER SYS$NODE "''node'"
$ DEFINE/USER KERMIT SYS$HELP:KERMIT.HLB ! in case user has a logical name KERMI
T
$ DEFINE/USER KER$COMM 'KER_LINE'
$ DEFINE/USER SYS$INPUT SYS$COMMAND
$ KERMIT 'command'
$ IFF (Allocated .NES. "") THEN DO_TO EndIf13
$    DEALLOCATE 'Allocated'
$    WRITE SYS$OUTPUT "%KERMIT-I-DEALL, ",Allocated," deallocated"
$ EndIf13:
$ GOTO END

!
!       Clean up after <CTRL/Y>
!
$ CTRL_Y_EXIT:
$ WRITE SYS$OUTPUT "[ Returning to ",node," ]"

!
!       Normal Exit
!
$ END: Verify = F$VERIFY(Verify)




=============================== KERMIT.HLP ===================================

1 KERMIT
 KERMIT is a file transfer utility that can be used to move files
 to any other computer that has a KERMIT.

 FORMAT:

        KERMIT  [command]

 KERMIT operates in one of two modes:  LOCAL mode and REMOTE mode.
 Specify  LOCAL mode if you intend to use the CONNECT command; use
 REMOTE mode if you will use  KERMIT  as a SERVER.  You should not
 need  to use the  SET LINE  command, as  KERMIT will allocate the
 proper line for you.

2 Parameters
 Use the Kermit HELP command for information on the KERMIT commands:

        KERMIT-32> HELP

2 Qualifiers
/CONNECT

        /CONNECT
        /NOCONNECT

 Specifies  whether you  intend to  use the CONNECT command or not.
 /CONNECT is the same as /LOCAL; /NOCONNECT is the same as /REMOTE.

/LOCAL

 Specifies that the Kermit will be used as a LOCAL Kermit; that is,
 it will  be  used as  a  virtual  terminal to  CONNECT  to another
 computer, where another Kermit will be run as a REMOTE Kermit.  If
 you  specify the  /LOCAL  qualifier, the  default  line  for  file
 transfer will  be one that connects you to the  DataSwitch so that
 you can log into  another computer from there.  Be sure to set the
 parity (use the Kermit SET PARITY command) to that required by the
 other computer.

/REMOTE

 Specifies that  the Kermit  will be used as a REMOTE Kermit.  Most
 often, this means that you have logged  onto another computer, run
 Kermit as a  LOCAL,  CONNECTed to the DataSwitch, then logged onto
 the  KVAX  and wish to start Kermit on the KVAX as a  SERVER.  The
 /REMOTE qualifier sets up  the  proper line for  file transfer, so
 you should not need to give the  SET LINE command.  If you specify
 the /REMOTE qualifier, you should not use the CONNECT command.

DPVC@UORDBV.BITNET (02/12/86)

May last transmission had long lines (over 80 characters), so they were
wrapped. So I'm re-submitting this.  Sorry for any problems.

I sent this some months ago, but never saw it on the net, so I am trying
to send it again.  Sorry for the delay.

>Date: Thu, 17 Oct 85 21:53:16 edt
>From: faron!sidney@mitre-bedford.ARPA
>Subject: Dropping DTR on VMS
>
>We have the latest VMS Kermit running under VMS 4.whatever, talking to
>an autodial modem through a DMF-32 mux. The only way the VAX can get
>the modem to hang up the phone is by dopping DTR. Can anyone help with
>a way to do that, perhaps with a little program like the one that was
>in the last info-kermit digest for MSDOS? Are there any VMS SET TERM
>parameters that are involved?
>
>                    Sidney Markowitz
>

The /[NO]MODEM qualifier of the SET TERMINAL command is the one you will need
to use.  Going from MODEM to NOMODEM hangs up the line (I have heard, however,
that some DMF-32s do not support modem control properly; we use DZ-11s, here,
and DMF-32 emulators that support modem control).  Unfortunately, KERMIT does
not set the line to MODEM for you so you must remember to do this yourself
whenever you intend to use the CONNECT command.  To do this, make sure the
line is NOMODEM by default (SET TERMINAL/NOMODEM/PERMANENT KER$COMM). When you
wish to use KERMIT, allocate the line (ALLOCATE KER$COMM) and then set it to
MODEM (SET TERMINAL/MODEM KER$COMM) then run KERMIT.  When you are done,
deallocate the line (DEALLOCATE KER$COMM); this will cause the line to revert
to its default state (NOMODEM), which hangs up the line.  Note that, if you
forget to deallocate the line, it is deallocated automatically when you log
off; this is the reason for having NOMODEM the default (that way, the line is
hung up automatically when you log off).

Since people are generally forgetful, it is best to have a command procedure
that handles these details for them.  The following is such a command
procedure, which includes many additional features.  Its main purpose is to
allocate the proper line and set it to MODEM control, but as we have more than
one outgoing line, I included the ability to choice from among any number of
lines (these are identified by the logical names KER$COMM1, KER$COMM2, ...).
In addition, we use KERMIT both as a local kermit (one that use the CONNECT
command), and as a remote (one that usually runs as a SERVER), but we don't
want people to allocate outgoing lines that they don't need.  Furthermore, we
don't want users to have to SET LINE SYS$INPUT when they are using KERMIT as a
remote (they always seem to forget that).  Thus we wanted KERMIT to choose the
line for them, taking into account the expected use of KERMIT (local or remote),
the availability of any of a number of lines, and the posibility that the user
already has one of these lines in use (pre-allocated).  The command procedure
that follows performs these functions.

This procedure also sets up (temporarily) the logical name SYS$NODE if it's
not defined (VMS KERMIT uses this when it reports its connect messages), and
if you use control-C or control-Y to exit from a remote terminal session, it
tells you that you have returned to the local VAX (this is very helpful if the
remote also is a VAX, and you happen to cancel a directory listing of
something; without this warning, it looks like you are still using the remote,
while actually, you have cancelled KERMIT as well, and are back at the local
VAX).

See the instructions in the comments at the top of the procedure for the
definition of the KERMIT symbol.  The comments within the procedure should
explain what actually is happening.  I know it looks ugly in places, and seems
long, but it has quite a bit of work to do, and DEC does not support control
structures in DCL.

IF you are using version 3.x of VMS, then replace line 90 (which uses
the new lexical function F$ELEMENT) by the following three lines

$    qualifiers = F$EXTRACT(1,-1,qualifiers)
                                    ! cut out "/" (so F$LOCATE won't find it)
$    pos = F$LOCATE("/",qualifiers)             ! find next qualifer, if any
$    qual = F$EXTRACT(0,pos,qualifiers)         ! save qualifier name

Also, replace F$TRNLNM by F$LOGICAL in lines 145 and 237.

A (short) help file for this new KERMIT command and its qualifiers is included
after the body of the command procedure.

If you have difficulties with this procedure, please feel free to contact me.

                                        Davide P. Cervone

                                        BITNET:  DPVC@UORDBV


=============================== KERMIT.COM ===================================


$ Verify = F$VERIFY(0)
!-----------------------------------------------------------------------------
!
! KERMIT.COM            Version 1.1     12-FEB-1985
!
! PURPOSE:
!       To allocate KER$COMM only when needed, and then SET TERM/MODEM KER$COMM
!       and to choose from among (possibly) many outgoing lines.
!       The user specifies whether the kermit will be used as a Local or
!       Remote kermit.
!
! ENVIRONMENT:
!       Can be run by any user, without requiring privileges.
!       Runs under the VMS operating system, last tested VMS version 4.1
!       Runs LOCAL$EXE:KERMIT.EXE
!       Allocates a terminal line (specified by KER$COMM or KER$COMM#)
!
! SYMBOL DEFINITION:
!       KERMIT :== @KERMIT.COM n
!       where n is the number of KER$COMM# logicals (i.e., the number
!       of out-going lines available).  If n=0, then KER$COMM is used.
!       For instance, if n=2, then KER$COMM1 and KER$COMM2 should point
!       to the two outgoing terminal lines
!
! CALLING SEQUENCE:
!       $ KERMIT [/REMOTE] [/LOCAL] [command]
!       where /LOCAL means KERMIT will use the CONNECT command, and
!       /REMOTE means it won't.  Since this sometimes is confusing,
!       synonimous qualifiers /CONNECT (for /LOCAL) and /NOCONNECT
!       (for /REMOTE) are provided.
!
! REVISION HISTORY:
!     Version      Date             Who                 Project Description
!     -------      ----             ---                 -------------------
!       1.0     12-FEB-1985     Davide P. Cervone       Wrote it
!       1.1     27-FEB-1985     Davide P. Cervone       Added ability to check
!                                                       multiple KER$COMM lines
!       1.1     14-AUG-1985     Davide P. Cervone       Added check for OPA0,
!                                                       since using KERMIT from
!                                                       the operator's
!                                                       terminal crashes the VAX
!       1.1     25-OCT-1985     Davide P. Cervone       Make it a little more
!                                                       generic, so that I can
!                                                       send it for distribution
!
!-----------------------------------------------------------------------------

!
!       Definitions needed to make structured IF statements
!
$ IFF := IF .NOT.
$ DO_TO := GOTO

!
!       Set up defaults, and get input from keyboard
!
$ ON WARNING THEN EXIT          ! EXIT on any error or warning
$ IF "''KER_LINE'" .EQS. "" THEN KER_LINE == ""
                                ! Set up KER_LINE for storing last used line
$ Kerm = "LOCAL"                ! specifies LOCAL or REMOTE kermit
$ Specified = "FALSE"           ! tells whether a qualifier was used
                                !      (otherwise prompt)
$ Allocated = ""                ! holds name of line allocated (to DEALLOCATE)

!
!       Create qualifier list from parameters that start with "/"
!
$ n = 2                         ! specifies what parameter we are using
$ qualifiers = ""               ! start with no qualifiers
$ Loop1:
$ IFF ((F$EXTRACT(0,1,p'n') .EQS. "/") .OR. -
       (F$EXTRACT(F$LENGTH(qualifiers)-1,1,qualifiers) .EQS. "/")) -
            THEN DO_TO EndLoop1
$    qualifiers = qualifiers + p'n'
$    n = n + 1
$    IF n .LT. 9 THEN GOTO Loop1
$ EndLoop1:

!
!       Create command string from all remaining parameters;
!       this will be passed to KERMIT as a foreign command line
!
$ command = ""
$ Loop2:
$ IF n .GT. 8 THEN GOTO EndLoop2
$    command = command + " " + p'n'
$    n = n + 1
$    GOTO Loop2
$ EndLoop2:

!
!       Check for qualifiers:  /LOCAL or /CONNECT mean allocate line,
!                              /REMOTE or /NOCONNECT mean don't need line
!
!       Abbreviations are allowed; any other qualifier is an error
!
$ Loop3:
$ IFF (F$EXTRACT(0,1,qualifiers) .EQS. "/") THEN DO_TO EndLoop3
$    Specified = "TRUE"                         ! qualifier is present
$    qual = F$ELEMENT(1,"/",qualifiers)         ! get the first qualifier
$    IFF (qual .EQS. "") THEN DO_TO EndIf1      ! will error if no qualifier
                                                ! was given
$       WRITE SYS$ERROR "%KERM-E-NOQUAL, no qualifier keyword"
$       WRITE SYS$ERROR "  \\",qualifiers"
$       EXIT
$    EndIf1:
$    qualifiers = qualifiers - "/" - qual       ! remove qual from list
$    IFF ((F$LOCATE(qual,"CONNECT") .EQ. 0) .OR. -
          (F$LOCATE(qual,"LOCAL") .EQ. 0))  THEN DO_TO Else2
$       Kerm = "LOCAL"
$       GOTO EndIf2
$      Else2:
$       IFF ((F$LOCATE(qual,"NOCONNECT") .EQ. 0) .OR. -
             (F$LOCATE(qual,"REMOTE") .EQ. 0))   THEN DO_TO Else3
$          Kerm = "REMOTE"
$          GOTO EndIf3
$         Else3:
$          WRITE SYS$ERROR "%KERM-E-ILQUAL, illegal qualifier keyword"
$          WRITE SYS$ERROR "  \",qual,"\"
$          EXIT
$       EndIf3:
$    EndIf2:
$    IF qualifiers .NES. "" THEN GOTO Loop3
$ EndLoop3:

!
!       If user requests /REMOTE, then we can go right on to running KERMIT
!       (no need to look for lines since the transfer line for remotes
!       is SYS$INPUT)
!
$ IFF (kerm .EQS. "REMOTE") THEN DO_TO EndIf15
$    KER_LINE :== SYS$INPUT
$    GOTO RUN_KERMIT
$ EndIf15:

!
!       Choose which line to use:  if no extra lines (i.e., p1=0) then
!       use KER$COMM; otherwise, if we were using a line before (i.e.,
!       KER_LINE <> "") then check if we still own it, if so use that one
!       (we may have used ^C to get out, leaving KERMIT connected); if not,
!       then look throught the logicals KER$COMMn for lines that we own (use
!       these first) or lines that are free; if none, then KER_LINE="".
!
$ PID = F$GETJPI("","PID")
$ IFF (p1 .LE. 0) THEN DO_TO Else4
$    KER_LINE :== KER$COMM
$    GOTO EndIf4
$   Else4:
$    IF KER_LINE .NES. "" THEN -
$       IF F$GETDVI(KER_LINE,"PID") .NES. PID THEN KER_LINE == ""
!    EndIf:
$    IFF (KER_LINE .EQS. "") THEN DO_TO EndIf5
$       n = p1
$       KER_FREE = ""
$       Loop4:
$          KER_TEST = F$TRNLNM("KER$COMM''n'")
$          IFF (KER_TEST .NES. "") THEN DO_TO EndIf6
$             Line_PID = F$GETDVI(KER_TEST,"PID")
$             IF Line_PID .EQS. PID THEN KER_LINE == KER_TEST
$             IF Line_PID .EQS. ""  THEN KER_FREE =  KER_TEST
$          EndIf6:
$          n = n - 1
$          IF (n .GT. 0) .AND. (KER_LINE .EQS. "") THEN GOTO Loop4
$       EndLoop4:
$       IF KER_LINE .EQS. "" THEN KER_LINE == KER_FREE
$    EndIf5:
$ EndIf4:

!
!       Set KER_LINE to the name of the line and find out whether we can
!       get the line defined by KER_LINE.
!
$ can_get_line = "FALSE"
$ IFF (KER_LINE .NES. "") THEN DO_TO EndIf7
$    KER_LINE == F$GETDVI(KER_LINE,"DEVNAM")
$    Line_PID =  F$GETDVI(KER_LINE,"PID")
$    IF (Line_PID .EQS. PID) .OR. (Line_PID .EQS. "") THEN can_get_line = "TRUE"
$ EndIf7:

!
!       If no qualifer was specified and if KER$COMM is available
!       then find out whether the user needs the line or not;
!
$ IFF ((.NOT. Specified) .AND. can_get_line) THEN DO_TO EndIf8
$    INQUIRE/NOPUNCT qual "Use KERMIT as Local or Remote (L or R) [R]? "
$    Kerm = ""
$    IF F$LOCATE(qual,"LOCAL")  .EQ. 0 THEN Kerm = "LOCAL"
$    IF F$LOCATE(qual,"REMOTE") .EQ. 0 THEN Kerm = "REMOTE"
$    IFF (Kerm .EQS. "") THEN DO_TO EndIf9
$       WRITE SYS$ERROR "%KERM-E-NOTLOR, KERMIT must be LOCAL or REMOTE"
$       EXIT
$    EndIf9:
$ EndIf8:

!
!       If Local Kermit is requested, then find out if the KER$COMM
!       line is allocated or if we can get it;
!       If it is available, allocate it, set it to MODEM, and save the name
!       so that we can deallocate it later.
!       If unavailable, then give an appropriate message, and EXIT if the
!       user requested a LOCAL kermit with a qualifier; if no qualifier
!       was used, then the message is a warning, and the transefer line is
!       set so that KERMIT can be used as a REMOTE.
!
!       If the user specified a REMOTE kermit, there is no need to allocate
!       a line, so KER_LINE is set up for REMOTE use.
!
$ IFF (Kerm .EQS. "LOCAL") THEN DO_TO Else10
$    IFF (KER_LINE .NES. "") THEN DO_TO Else11
$       IFF (can_get_line) THEN DO_TO Else12
$         IFF F$GETJPI("","TERMINAL") .EQS. "OPA0:" THEN DO_TO EndIf14
$            WRITE SYS$ERROR -
                "%KERM-E-NOOPER, operators can't use kermit from OPA0:"
$            STOP
$         EndIf14:
$         ALLOCATE 'KER_LINE'
$         SET TERMINAL/MODEM 'KER_LINE' ! set other line characteristics here
$         Allocated = KER_LINE
$         GOTO EndIf12
$        ELSE12:
$          WRITE SYS$ERROR -
              "%KERM-E-LINEALL, communication line is allocated to another user"
$          WRITE SYS$ERROR "             KERMIT can be used only as a REMOTE"
$          IF Specified THEN EXIT
$          KER_LINE := SYS$INPUT
$       EndIf12:
$       GOTO EndIf11
$      ELSE11:
$       WRITE SYS$ERROR "%KERM-E-NOCOMM, no communication line defined"
$       WRITE SYS$ERROR "                KERMIT can be used only as a REMOTE"
$       IF Specified THEN EXIT
$       KER_LINE := SYS$INPUT
$    EndIf11:
$    GOTO Endif10
$   ELSE10:
$    KER_LINE := SYS$INPUT
$ EndIf10:


 Run_Kermit:

!
!       Call SYS$SYSTEM:KERMIT.EXE with the appropriate command line and
!       communication line, and DEALLOCATE KER$COMM if the line was
!       allocated earlier
!
$ ON CONTROL_Y THEN GOTO CTRL_Y_EXIT
$ WRITE SYS$OUTPUT ""
$ KERMIT := $KERMIT.exe
$ node = F$TRNLNM("SYS$NODE")
$ IF node .EQS. "" THEN node = "VAX::"  ! for if DECNET is not running
$ DEFINE/USER SYS$NODE "''node'"
$ DEFINE/USER KERMIT SYS$HELP:KERMIT.HLB
                                 ! in case user has a logical name KERMIT
$ DEFINE/USER KER$COMM 'KER_LINE'
$ DEFINE/USER SYS$INPUT SYS$COMMAND
$ KERMIT 'command'
$ IFF (Allocated .NES. "") THEN DO_TO EndIf13
$    DEALLOCATE 'Allocated'
$    WRITE SYS$OUTPUT "%KERMIT-I-DEALL, ",Allocated," deallocated"
$ EndIf13:
$ GOTO END

!
!       Clean up after <CTRL/Y>
!
$ CTRL_Y_EXIT:
$ WRITE SYS$OUTPUT "[ Returning to ",node," ]"

!
!       Normal Exit
!
$ END: Verify = F$VERIFY(Verify)




=============================== KERMIT.HLP ===================================

1 KERMIT
 KERMIT is a file transfer utility that can be used to move files
 to any other computer that has a KERMIT.

 FORMAT:

        KERMIT  [command]

 KERMIT operates in one of two modes:  LOCAL mode and REMOTE mode.
 Specify  LOCAL mode if you intend to use the CONNECT command; use
 REMOTE mode if you will use  KERMIT  as a SERVER.  You should not
 need  to use the  SET LINE  command, as  KERMIT will allocate the
 proper line for you.

2 Parameters
 Use the Kermit HELP command for information on the KERMIT commands:

        KERMIT-32> HELP

2 Qualifiers
/CONNECT

        /CONNECT
        /NOCONNECT

 Specifies  whether you  intend to  use the CONNECT command or not.
 /CONNECT is the same as /LOCAL; /NOCONNECT is the same as /REMOTE.

/LOCAL

 Specifies that the Kermit will be used as a LOCAL Kermit; that is,
 it will  be  used as  a  virtual  terminal to  CONNECT  to another
 computer, where another Kermit will be run as a REMOTE Kermit.  If
 you  specify the  /LOCAL  qualifier, the  default  line  for  file
 transfer will  be one that connects you to the  DataSwitch so that
 you can log into  another computer from there.  Be sure to set the
 parity (use the Kermit SET PARITY command) to that required by the
 other computer.

/REMOTE

 Specifies that  the Kermit  will be used as a REMOTE Kermit.  Most
 often, this means that you have logged  onto another computer, run
 Kermit as a  LOCAL,  CONNECTed to the DataSwitch, then logged onto
 the  KVAX  and wish to start Kermit on the KVAX as a  SERVER.  The
 /REMOTE qualifier sets up  the  proper line for  file transfer, so
 you should not need to give the  SET LINE command.  If you specify
 the /REMOTE qualifier, you should not use the CONNECT command.