From:	HENRY::IN%"HANEWINK%dm0mpb51.bitnet%wiscvm.wisc.edu%kl.sri.COM%relay.cs.net@RCA.COM" 25-APR-1987 16:49
To:	INFO-VAX@kl.sri.com
Subj:	executing commands on remote nodes

Some days ago J.Leichter posted a short command file for a remote
SHOW NET server. To manage 4 micro VAXes I use a more flexible version
to execute commands on a remote node. It executes any VMS command on
one or all remote nodes.
It consists of a sender (XREMOTE.COM) and the remote server (RECEIVE.COM),
which has to be in your login directory on the remote node or in the
DECNET default directory (if you have'nt proxy accounts).
The wildcard option requires a logical name which has to be defined in
the following form:

          $define MPI$ALL_NODES "node1::node2::node3::node4::"

On our site it is a system wide logical name on all nodes.
Here are the two procedures:

$! XREMOTE   execute a command on one or all remote nodes
$!       created  28-mar-87  H.Hanewinkel
$!
$!       P1   receiving node or * (for all nodes)
$!            for all nodes the logical name MPI$ALL_NODES has to be
$!            defined
$!       P2   command line for remote node
$!
$!       eg.: @xremote DOCMIC::sho que /all/full
$!            @xremote *::sho err
$!
$ set noon
$ if P1 .eqs. "" then inquire P1 "_node"
$ if f$locate("::",p1) .eq. 0 then p1 = p1 + "::"
$ l = f$locate("::",p1)
$ if f$length(p1) .gt. l + 2 then p2 = f$extract(l+2,f$length(p1)-l-2,p1) -
                                  + " " + p2
$ p1 = f$extract(0,l+2,p1)
$ prom = "_" + f$extract(0,l,p1) + "_$ "
$ if P2 .eqs. "" then inquire /nopunctation p2 "''prom'"
$!
$ if p1 .eqs. "*::" then goto all
$ remote = p1
$ gosub senrem
$X1:
$ set on
$ exit
$!---------------------------
$all:
$ node = f$trnlnm("SYS$NODE")
$ cnt = 0
$next:
$ remote = f$element(cnt,":",f$trnlnm("MPI$ALL_NODES")) + "::"
$ if remote .eqs "::" then goto x1
$ cnt = cnt + 2
$ if node .eqs. remote then goto next
$ write sys$output "%XREMOTE-I- executing on node ''remote'"
$ gosub senrem
$ goto next
$! -------
$SENREM:
$ open/write net 'remote'"task=receive"
$ write net "''p2' ''p3' ''p4' ''p5' ''p6' ''p7' ''p8'"
$LOOP:
$ read/end=enet/err=enet net line
$ write sys$output line
$ goto loop
$ENET:
$ close net
$ return

--------------------------------------------------------


$! RECEIVE.COM remote command server,
$! executes commands received from a remote node
$!    created 27-mar-1987 H. Hanewinkel
$!
$ set noon
$ open/write net sys$net    ! open the link
$ read net line            ! get the command
$ define sys$output net        ! send output there
$ define sys$error  net
$ 'line'            ! execute the command
$ deassign sys$output        ! disconnect
$ deassign sys$error        !  link
$ close net            !
$ exit                !  and exit



Herbert Hanewinkel                         hanewink@dm0mpb51
Max-Planck-Institut fuer Biochemie
D-8033 Matrinsried
