From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 31-AUG-1989 23:36
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Work-around for single-user limitation of DECWindow VMS Workstation

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 31 AUG 89 19:47:46 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Thu, 31 Aug 89 19:45:23 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA25525; Thu, 31 Aug 89 19:32:53 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 1 Sep 89 02:07:00 GMT
From: gjc@bu-cs.bu.edu  (George J. Carrette)
Organization: Boston U. Comp. Sci.
Subject: Work-around for single-user limitation of DECWindow VMS Workstation
Message-Id: <37391@bu-cs.BU.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

The command file at the end of this message can be useful in
other situations besides its use on workstations.

It is possible while debugging to do stupid things that blow away your
window manager process and/or wedge the session manager in some way.
No big deal. But how do you unwedge things? Go to another VAX and SET
HOST xxx, and log in and STOP the offending processes and restart
decwindows?  NO! You cannot because of the single-user limitation.
Instead you hit the HALT button and reboot the system. You might as
well be using a primitive system like a MacIntosh with the
"programmers button" (that is what people call the "halt switch" on a
MAC-II).

Things aren't really that bad, you can always use SUBMIT/REMOTE, but
here is another case of DECNET object "0" to the rescue. 

$! SORT OF AN RSH (REMOTE-SHELL) FOR VMS SYSTEMS
$! 31-AUG-89 George Carrette, Mitech Corporation. GJC@MITECH.COM
$!
$! Have a copy of this file in your login directory on the system to
$! which you want to connect to for remote DCL operations. In interactive
$! mode it takes a host name as P1, a username as P2 and a password as P3.
$!
$! Possible usage: Unwedge a workstation/session-manager where you 
$!                 cannot log into with SET HOST because of the licensed
$!                 interactive user limitation of 1.
$!
$! 
$! Bugs: * Some commands such as forms of EXIT and GOTO may
$!         have undesirable effects because of the execution context.
$!       * images executed that want to take input from SYS$INPUT
$!         or a terminal will either see an END-OF-FILE or will
$!         get some other error. 
$!
$ EOT = "$*$-END-OF-OUTPUT-$*$"
$!
$ IF F$MODE() .EQS. "INTERACTIVE" THEN GOTO DO_INTERACTIVE
$ IF F$MODE() .EQS. "NETWORK" THEN GOTO DO_NETWORK
$ EXIT
$!
$DO_NETWORK:
$ OPEN/ERROR=DO_NETWORK_OPEN_ERROR/READ/WRITE NET_CHAN SYS$NET:
$ OPEN/WRITE NETCMD_SYS_OUTPUT SYS$OUTPUT:
$!
$ DEFINE/NOLOG SYS$OUTPUT NET_CHAN:
$ DEFINE/NOLOG SYS$ERROR  NET_CHAN:
$!
$DO_NETWORK_LOOP:
$ READ/END=DO_NETWORK_EOF/ERROR=DO_NETWORK_ERROR NET_CHAN NET_CMD
$ WRITE NETCMD_SYS_OUTPUT "Executing: " + NET_CMD
$ ON ERROR THEN GOTO NET_CMD_ERROR
$ 'NET_CMD'
$  WRITE NET_CHAN EOT
$ GOTO DO_NETWORK_LOOP
$NET_CMD_ERROR:
$  WRITE NET_CHAN EOT
$ GOTO DO_NETWORK_LOOP
$!
$DO_NETWORK_ERROR:
$ WRITE NETCMD_SYS_OUTPUT "Error code from SYS$NET: " + $STATUS
$ CLOSE NET_CHAN
$ EXIT $STATUS
$DO_NETWORK_EOF:
$ WRITE NETCMD_SYS_OUTPUT "End of file on SYS$NET"
$ CLOSE NET_CHAN
$ EXIT
$DO_NETWORK_OPEN_ERROR:
$ WRITE NETCMD_SYS_OUTPUT "Error opening network: " + $STATUS
$ EXIT $STATUS
$!
$!
$!
$!
$DO_INTERACTIVE:
$!
$ HOST = P1
$ IF HOST .EQS. "" THEN HOST = F$TRN("SYS$NODE")
$!
$ USER = P2
$ IF USER .EQS. "" THEN USER = F$EDIT(F$GETJPI("","USERNAME"),"TRIM")
$!
$ PASS = P3
$ IF PASS .NES. "" THEN PASS = " " + PASS
$!
$ HOST = F$EXTRACT(0,F$LOCATE(":",HOST),HOST)
$ HOST = F$EXTRACT(0,F$LOCATE(":",HOST),HOST)
$
$ WRITE SYS$OUTPUT "Connecting to NETCMD on host ''HOST' for ''USER'"
$!
$ NM = F$PARSE(F$ENV("PROCEDURE"),,,"NAME")
$!
$ OPEN/ERROR=DO_INTERACTIVE_OPEN_ERROR/READ/WRITE -
  NET_CHAN 'HOST'"''USER'''PASS'"::"0=''NM'"
$!
$DO_INTERACTIVE_LOOP:
$read/end=KBD_EOF/err=DO_INTERACTIVE_LOOP/prompt="CMD: " sys$command cmd_rec
$ Z = F$EDIT(CMD_REC,"UPCASE,TRIM")
$ Z = F$EXTRACT(0,F$LOCATE(" ",Z),Z)
$ IF Z .EQS. "EXIT" THEN GOTO BAD_CMD
$ IF Z .EQS. "GOTO" THEN GOTO BAD_CMD
$write net_chan cmd_rec
$GOTO CMD_BACK_LOOP
$BAD_CMD:
$ WRITE SYS$OUTPUT "Certain DCL commands should not be used, such as: " + Z
$ GOTO DO_INTERACTIVE_LOOP
$!
$cmd_back_loop:
$read/end=cmd_back_eof/err=cmd_back_err net_chan ret_rec
$ if ret_rec .eqs. eot then goto do_interactive_loop
$ write sys$output ret_rec
$ goto cmd_back_loop
$cmd_back_eof:
$ write sys$Output "End of file on network connection"
$ close net_chan
$ exit
$cmd_back_err:
$ write sys$output "Error reading from network: " + $STATUS
$ close net_chan
$ exit $STATUS
$KBD_EOF:
$ write sys$output "[EXIT]"
$ close net_chan
$ exit
$!
$DO_INTERACTIVE_OPEN_ERROR:
$ WRITE SYS$OUTPUT "Error opening network: " + $STATUS
$ EXIT $STATUS

