From:	CSBVAX::MRGATE!MASSEY%CMS1@tqms.llnl.gov@SMTP 11-APR-1988 12:01
To:	ARISIA::EVERHART
Subj:	Remote management of VAXstations


Received: from tqms.llnl.gov by KL.SRI.COM with TCP; Fri 8 Apr 88 17:07:40-PDT
Date: Fri, 8 Apr 88 17:06 PST
From: "Massey%CMS1@ICDC.LLNL.GOV Bldg235 Rm1064 L-352 (415)422-1958"
 <MASSEY%CMS1@tqms.llnl.gov>
Subject: Remote management of VAXstations
To: INFO-VAX@KL.SRI.COM
X-VMS-To: INFOVAX

John Macallister says:

 > In short, TO REBOOT A VAXSTATION ONE MUST BE PHYSICALLY PRESENT AT THE
 >  VAXSTATION TO TYPE IN THE SHUTDOWN/BOOT COMMANDS! Imagine trying to manage
 >  VAXstations in a large department! ( Only one locked door is sufficient to
 >  make things impossible. )


To shut down or reboot a VAX from a remote location, try the following command
procedure. Something else to consider is that when you are doing VMSINSTALs of
certain pieces of software, SYS$SYSTEM:SHUTDOWN.COM can be automatically invoked
as part of the install procedure. If you are doing the install over the network
and this happens, you will be left with a crippled machine that will require a
personal visit to get it going again. To prevent this from happening, rename or
move SHUTDOWN.COM so that VMSINSTAL cannot get to it. SHUTDOWN.COM has another
quirk that can foul things up which is documented in the following procedure.

Warren Massey
Lawrence Livermore National Laboratory
P.O. Box 808, L-352
Livermore, Calif. 94550

MASSEY%CMS1@TQMS.LLNL.GOV
MASSEY%CMS1@ICDC.LLNL.GOV
MASSEY%CMS1@CIRCUS.LLNL.GOV

The opinions expressed herein are purely my own and do not represent in any 
way the opinions of my employer. No claims are made as to the accuracy or
correctness of information contained herein.


....................... Cut between dotted lines and save ......................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.03 07-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by MASSEY
$! on Friday 8-APR-1988 16:54:04.22
$!
$! It contains the following 1 file:
$! REMOTE_SHUTDOWN.COM
$!=============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="REMOTE_SHUTDOWN.COM"
$ Check_Sum_is=1047391752
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$! 04/08/88 -WNM- Remote_Shutdown.Com
X$!
X$!`009ROUTINE USED TO SHUTDOWN/REBOOT VMS 4.x SYSTEM FROM A REMOTE LOCATION
X$!
X$! P1 is an optional time (Absolute, Delta or Combination) argument specifying
X$! the amount of time to delay the execution of the detached job.
X$!
X$! P2 is an optional integer argument specifying the shutdown delay (in
X$! minutes) which will be used. 
X$!
X$! P3 is an optional argument which specifies if the system is to be rebooted
X$! after the shutdown. If a reboot is desired, P3 should be YES or TRUE.
X$!
X$! 
X$ On Warning Then Goto X_it
X$ On Control_Y Then Goto X_it
X$!
X$ Success = 1`009`009`009`009! $Severity value if successful
X$ Say := Write Sys$Output
X$!
X$!
X$ User_Name = F$Edit( F$GetJpi( "", "USERNAME" ), "COLLAPSE" )
X$ IF( User_Name .EQS. "SYSTEM" ) THEN Goto Set_Privs
X$ Say ""
X$ Say "This procedure can only be run from the SYSTEM account."
X$ Exit
X$!
X$!
X$Set_Privs:
X$ Required_Privs = "SETPRV,SYSNAM,DETACH"
X$ GoSub PrivCheck`009`009`009! Make sure we have required privileges
X$! 
X$ DelayLogical  = "Shutdown_Delay"
X$ RebootLogical = "Auto_Reboot"
X$ IF( F$Mode() .EQS. "OTHER" ) THEN Goto We_Are_Detached
X$!
X$ IF( P1 .NES. "" ) THEN GoSub P1_Check
X$ IF( P1 .EQS. "" ) THEN GoSub Ask_About_P1
X$!
X$ IF( P2 .NES. "" ) THEN GoSub P2_Check
X$ IF( P2 .EQS. "" ) THEN GoSub Ask_About_P2
X$!
X$ IF( P3 .EQS. "" ) THEN GoSub Ask_About_P3
X$!
X$!
X$! Pass values to detached job via a system logicals
X$ Set Message /NoFacility /NoIdentification /NoSeverity /NoText
X$ Define/System 'DelayLogical'  'Warning_Time'
X$ Define/System 'RebootLogical' 'P3'
X$ Set Message /Facility   /Identification   /Severity   /Text
X$!
X$!
X$ ThisFileSpec  = F$Environment("Procedure")
X$ ThisDirectory = F$Parse( ThisFileSpec,,, "Device" ) -
X                + F$Parse( ThisFileSpec,,, "Directory" )
X$! 
X$!
X$ RUN`009`009SYS$SYSTEM:LOGINOUT -
X`009`009/Process_Name = ShutDown -
X`009`009/Schedule = "''Run_Time'" -
X`009`009/Input  = 'ThisFileSpec' -
X`009`009/Output = 'ThisDirectory'Remote_ShutDown.Log -
X`009`009/Error  = 'ThisDirectory'Remote_ShutDown.Log -
X`009`009/Priv = (ALL) -
X`009`009/UIC = [SYSTEM] -
X`009`009/Authorize
X$
X$ Say ""
X$ IF( F$CvTime( "" ) .GES. F$CvTime( Run_Time ) ) THEN Goto SAY_NOW
X$ Say "The SHUTDOWN procedure should begin execution at ", Run_Time
X$ Goto X_it
X$! 
X$Say_NOW:
X$ Say "The SHUTDOWN procedure should begin execution shortly."
X$ Goto X_it
X$! 
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$PrivCheck:
X$ WeHaveRequired_Privs = F$Privilege( "''Required_Privs'" )
X$ IF( WeHaveRequired_Privs ) Then Return
X$ IF( F$Type( OldPrivs ) .NES. "" ) THEN Goto NoPriv
X$ OldPrivs = F$SetPrv( "''Required_Privs'" )
X$ Goto PrivCheck
X$NoPriv:
X$ Say ""
X$ Say "You do not have the required privilege to run this procedure."
X$ Say "''Required_Privs' privilege required."
X$ Say ""
X$ Goto X_it
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$P1_Check:
X$ Set Noon
X$ Set Message /NoFacility /NoIdentification /NoSeverity /NoText
X$!
V$ Run_Time = F$CvTime( P1, "Absolute" )`009! If P1 is Absolute or Combination 
Xtime
X$ IF( $Severity .EQ. Success ) THEN Goto P1_Check_Exit
X$ 1P = F$Time() + P1`009`009`009! Change Delta time to Combination time
X$!
V$ Run_Time = F$CvTime( 1P, "Absolute" )`009! If P1 is Absolute or Combination 
Xtime
X$ IF( $Severity .EQ. Success ) THEN Goto P1_Check_Exit
X$ Say ""
X$ Say "Bad time value = ", P1
X$ P1 = ""
X$!
X$P1_Check_Exit:
X$ Set On
X$ Set Message /Facility   /Identification   /Severity   /Text
X$ Return
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$Ask_About_P1:
X$ Type Sys$Input
X
V  You may specify the time that the detached shutdown process begins execution
X.
X  The time that you specify can be in Absolute, Delta or Combination format.
X  If you want the process to begin execution immediately, just press RETURN.
X
X$
X$ Inquire P1 "  Enter time for process execution to begin"
X$ IF( P1 .EQS. "" ) THEN P1 = F$Time()
X$ GoSub P1_Check
X$ IF( P1 .EQS. "" ) THEN Goto Ask_About_P1
X$ Return
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$P2_Check:
X$ Set Noon
X$ Set Message /NoFacility /NoIdentification /NoSeverity /NoText
X$!
X$ Warning_Time = 'P2`009`009`009`009! Change string to integer
X$ IF( $Severity .NE. Success ) THEN Goto Bad_P2_Value
X$ IF( Warning_Time .LT.  0 ) THEN Goto Bad_P2_Value
X$ IF( Warning_Time .GT. 99 ) THEN Goto Bad_P2_Value
X$ Goto P2_Check_Exit
X$!
X$Bad_P2_Value:
X$ Say ""
X$ Say "Bad minute value = ", P2
X$ P2 = ""
X$!
X$P2_Check_Exit:
X$ Set On
X$ Set Message /Facility   /Identification   /Severity   /Text
X$ Return
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$Ask_About_P2:
X$ Type Sys$Input
X
X  You may specify the number of minutes between the first SHUTDOWN warning
X  message and the system shutdown. The default value is 5 minutes.
X
X$
V$ Inquire P2 "  Enter number of minutes between 1st warning and system shutdow
Xn"
X$ IF( P2 .EQS. "" ) THEN P2 = 5
X$ GoSub P2_Check
X$ IF( P2 .EQS. "" ) THEN Goto Ask_About_P2
X$ Return
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$Ask_About_P3:
X$ Say ""
X$ Inquire P3 "  Do you want the system to be automatically rebooted? [Y]"
X$ IF( P3 .EQS. "" ) THEN P3 = "Y"
X$ Return
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!
X$!vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X$We_Are_Detached:`009`009`009`009! Mode = "OTHER"
X$ Shutdown_Delay = F$TrnLnm( DelayLogical )
X$ IF( "''Shutdown_Delay'" .EQS. "" ) THEN Shutdown_Delay = 5
X$!
X$ Auto_Reboot = F$TrnLnm( RebootLogical )
X$ IF( "''Auto_Reboot'" .EQS. "" ) THEN Auto_Reboot = "Y"
X$ IF( Auto_Reboot ) THEN Goto Want_to_Reboot
X$!
X$ Shutdown_Reason = "CIRCUMSTANCES MANDATE THAT THE SYSTEM BE SHUT DOWN"
X$ When_Available  = "AS SOON AS PRACTICAL"
X$ Auto_Reboot     = "NO"
X$ Goto Shutdown
X$!
X$Want_to_Reboot:
X$ Shutdown_Reason = "CIRCUMSTANCES MANDATE THAT THE SYSTEM BE REBOOTED"
X$ When_Available  = "SHORTLY"
X$ Auto_Reboot     = "YES"
X$!
X$Shutdown:
X$ Set NoVerify
X$ @SYS$SYSTEM:SHUTDOWN`009"''Shutdown_Delay'" -
X`009`009`009"''Shutdown_Reason'" -
X`009`009`009"NO" -
X`009`009`009"YES" -
X`009`009`009"''When_Available'" -
X`009`009`009"''Auto_Reboot'" -
X`009`009`009"REBOOT_CHECK"
X$
X$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
X$!
X$!
X$!
X$!`009Parameters for VMS 4.x "SYS$SYSTEM:SHUTDOWN.COM" are as follows:
X$!
X$!`009P1`009Number of minutes until shutdown`009`009(Numeric)
X$!`009P2`009Reason for shutdown`009`009`009`009(String)
X$!`009P3`009Spin down disks`009`009`009`009`009(Boolean)
X$!`009P4`009Invoke site-specific shutdown com file`009`009(Boolean)
X$!`009P5`009When will the system be rebooted`009`009(String)
X$!`009P6`009Enable automatic reboot`009`009`009`009(Boolean)
X$!`009P7`009Shutdown options`009`009`009`009(String)
X$!`009`009 (Valid responses: REBOOT_CHECK,
X$!`009`009    REMOVE_NODE, CLUSTER_SHUTDOWN)
X$!
X$! `009!!! The quoted-string Boolean values should be all upper case !!!
X$!
X$!   Note: The DEC-provided command file SYS$SYSTEM:SHUTDOWN.COM is used to
X$! accomplish the shutdown/reboot. This command file, if it detects an error,
X$! will abort the shutdown (and will most-likely leave you with a system that
X$! has most of its functionality turned off and in need of a reboot anyway).
X$!
X$! One potential source for an error when running this command file as a
X$! detached job is if it goes to broadcast a message and it cannot find anyone
X$! to receive the message. The resulting error message from this problem is:
X$!
X$!    %OPCOM-F-DEVOFFLINE, device is not in configuration or not available
X$!
X$! This problem has been seen on several MicroVAX systems so it may or may not
X$! not be a universal problem. If you wish, you can modify SHUTDOWN.COM in the
X$! following way to take care of this potential problem:
X$!
X$!    $ SET NOON`009`009`009! -ADDED LINE- Disable error checks
X$!    $reply'to_whom/bell/shutdown "''msg'"
X$!    $ SET ON`009`009`009`009! -ADDED LINE- Re-enable error checks
X$!
X$! The bad part about this is having to remember to do it each time VMS is
X$! updated.
X$!
X$!
X$!
X$X_it:
X$ IF( F$Type( OldPrivs ) .NES. "" ) THEN Junk = F$SetPrv( OldPrivs )
X$ Say ""
X$ Exit
$ GoSub Convert_File
$ Exit
