Cover V03, I03
Article
Figure 1
Figure 2
Figure 3
Figure 4
Listing 1
Listing 2
Listing 3
Sidebar 1

may94.tar


Listing 3: dnet_cmd.com VMS DECnet object

$!----------------------------------------------------
$! Filename: DNET_CMD.COM
$! Author:   Dave Brillhart
$!----------------------------------------------------
$! This procedure is executed as an object via DECnet.
$! It accepts either a single "batch" command or a
$! series of interactive commands - read from the
$! DECnet channel - and executes them via the local
$! machine's command interpertor. The commands' output
$! (both sys$output and sys$error) is sent back

$! through the DECnet channel.
$!----------------------------------------------------
$! Locate this DCL procedure in top level directory of
$! the account that is being asked to execute the
$! object.
$!----------------------------------------------------
$ set noverify
$ node = F$LOGICAL("SYS$NODE")
$ uic = F$USER()
$!----------------------------------------------------
$! Open the network channel (sys$net) for read&write,
$! get a single line and echo back the command.
$!----------------------------------------------------
$ get_new_cmd:
$   open/write decnet_link sys$net
$   read/end_of_file=cleanup/error=abort/time=30 -
decnet_link fromnet
$   if (F$LENGTH(fromnet) .le. 1) then goto cleanup
$   write decnet_link -
"RECEIVED CMD: ''fromnet' on ''node' as ''uic'"
$   write decnet_link "******************************"
$!----------------------------------------------------
$! Redirect output to a file, execute the command,
$! and undo the redirects.

$!----------------------------------------------------
$ assign decnet_cmd.tmp sys$error
$ assign decnet_cmd.tmp sys$output
$ 'fromnet'  !* execute command, output to temp file *
$ deassign sys$output
$ deassign sys$error
$!----------------------------------------------------
$! Open the file containing the command's output and
$! write it to the open channel.
$!----------------------------------------------------
$ open/read decnet_cmd_data decnet_cmd.tmp
$ readline:
$   read/end_of_file=cmd_done/error=cmd_done/time=1 -
decnet_cmd_data fromfile
$   write decnet_link "''fromfile' "
$   goto readline
$!----------------------------------------------------
$! Complete this command, delete the file, and go get
$! another command.
$!----------------------------------------------------
$ cmd_done:
$   write decnet_link "******************************"
$   write decnet_link "EOC"         !* Marker string *
$   close decnet_cmd_data
$   if (F$SEARCH("decnet_cmd.tmp") .NES. "") then -
delete decnet_cmd.tmp;*
$   goto get_new_cmd
$!----------------------------------------------------
$! Close the channel and exit.
$!----------------------------------------------------
$ cleanup:
$   write decnet_link "CLOSING DECNET CHANNEL"
$   write decnet_link ""
$   close decnet_link
$   exit
$ abort:
$   write decnet_link "ERROR: CLOSING DECNET CHANNEL"
$   close decnet_link
$   exit