$! This procedure is used to implement the remote mag tape utility for $! using a mag tape on the node defined by default by the logical name $! RMT_REMOTE_NODE. The default remote tape drive to be used is defined $! by the logical name RMT_REMOTE_TAPE, but the user is given the $! opportunity to override this. $! $! Usage : $! $! o Mount the tape on the remote node and put the drive on-line $! o @dev:[dir]RMT $! $! (Gory details at end of procedure) $! $! Written by : Bob Marshall $! 17 May 1993 $!************************************************************************** $! $ set noon $! $! First find out if there is a ZT device available; if not, we're out $! of luck anyway. $! $ n = 0 $! $ look_for_zt: $! $ zt_device = "ZTA" + f$string(n) $ zt_status = f$getdvi(ZT_DEVICE,"STS") $ if (zt_status .and. %X10) .eq. %X10 $ then $ n = n + 1 $ if n .le. 3 then goto look_for_zt $ type sys$input All of the ZT devices are in used at present. Try again later. $ exit $ endif $! $ default_remote_node = f$trnlnm("RMT_REMOTE_NODE") $ write sys$output "" $ if default_remote_node .eqs. "" $ then $ read/prompt="Name of node with tape drive : " sys$command remote_node $ if remote_node .eqs. "" then exit $ else $ read/prompt="Name of node with tape drive [''default_remote_node'] : " - sys$command remote_node $ if remote_node .eqs. "" then remote_node = default_remote_node $ endif $ remote_node = remote_node - "_" - "::" ! Strip off "::" just in case $ remote_node = f$edit(remote_node,"UPCASE") $! $ default_remote_tape = f$trnlnm("RMT_REMOTE_TAPE") $ if default_remote_tape .eqs. "" then default_remote_tape = "MUA0:" $! $ write sys$output "" $ read/prompt="Name of remote tape device [''default_remote_tape'] : " - sys$command remote_tape $ if remote_tape .eqs. "" then remote_tape = default_remote_tape $! $ write sys$output "" $ write sys$output - "Make sure the tape is mounted and ready to go. Then press " $ read/prompt="when you are ready to continue..." sys$command dummy $! $! Open the network link to the remote node $! $! (Note : to use an object number other than 142, specify that number here) $! $ write sys$output "" $ write sys$output "Attempting to create network link to ''remote_node'..." $ open/read/write/err=err_openlink netline 'remote_node'::"142=" $! $ this_node = f$trnlnm("sys$node") - "::" - "_" $ write netline this_node $ write netline remote_tape $ write netline zt_device $ on control_y then goto done $! $ write sys$output "" $ write sys$output "Stand by, ''remote_node' is attempting to mount the tape..." $! $ k = 0 $ not_loaded = "FALSE" $! $ readloop: $! $! Read any output from the remote side, looking for the string "**CONTINUE**" $! $ read/err=err_start_server netline message $ if f$locate("not software enabled",message) .ne. f$length(message) then - not_loaded = "TRUE" $ if message .eqs. "**ERROR**" then goto close $ if message .nes. "**CONTINUE**" $ then $ if message .nes. "" then - write sys$output "%''remote_node'-I-MESSAGE, ",message $ k = k + 1 $! if k .gt. 10 then goto err_start_server $ goto readloop $ endif $! $! At this point things seem to be OK on the remote side; now just wait for $! ZTAn: to come on-line. $! $ kwait = 0 $ write sys$output "" $! $ wait_for_ztan: $! $ write sys$output "Stand by, waiting for ''zt_device' to come on-line..." $ tape_status = f$getdvi(ZT_DEVICE,"STS") $ if (tape_status .and. %X10) .ne. %X10 $ then $ wait 00:00:05.00 $ kwait = kwait + 1 $ if kwait .lt. 20 then goto wait_for_ztan $ type sys$input Something appears to have gone haywire; bailing out... $ goto err_start_server $ endif $! $! OK, ZTAn: is on-line $! $ prompt = f$environment("PROMPT") $! For very long prompts, avoid string too long in spawn. $if f$length(prompt) .gt. 7 then prompt = "$" $ write sys$output "" $ write sys$output - "The local drive ''zt_device' is now on-line and ready to use. Please refer to" $ write sys$output - "device ''zt_device' in your subsequent commands." $ write sys$output "" $ write sys$output - "A subprocess will be spawned to allow you to use ''zt_device'. You may issue $ type sys$input any necessary commands, e.g., MOUNT, BACKUP, COPY, etc. When you are done with the drive, simply LOGOUT to terminate the subprocess and return control to this procedure. IMPORTANT : Due to a VMS bug, you should first ALLOCATE the device by issuing $ write sys$output "the command $ ALLOCATE ''zt_device'." $ write sys$output "" $ pid = f$getjpi("","pid") ! Generate a useful process name $ spawn/prompt="RMT_''prompt'"/process="RMT_''pid'" ! SPAWN $! $ done: $! $! Clean up (dismount tape, zap ZT2, close the link) $! $ set noon $ write sys$output "" $ write sys$output "Cleaning up..." $ if f$getdvi(ZT_DEVICE,"MNT") $ then $ write sys$output "Dismounting ''zt_device'..." $ dismount/nounload 'ZT_DEVICE' ! Remove the /NOUNLOAD after testing $ endif $ write sys$output "Terminating the ZT2 program..." $ zt2_forcex := $rmt$dir:zt2_forcex $ zt2_forcex RMT_'zt_device' $ write sys$output "Telling remote node that we are done..." $ write netline "**DONE**" $ read/err=continue netline message $ continue: $ wait 00:00:05.00 ! Give remote process time to die $! $ close: $! $ if not_loaded $ then $ write sys$output "" $ write sys$output - "The message 'Volume is not software enabled' means that the tape was not" $ write sys$output - "mounted on ''remote_tape', or the drive was not placed on-line. Please" $ write sys$output - "correct the condition and try again." $ write sys$output "" $ endif $ write sys$output "Closing network link..." $ close netline $ write sys$output "" $ exit $! $ err_openlink: $! $ error_message = f$message($status) $ write sys$output "" $ write sys$output - "%RMT-F-OPENLINK, Error opening network link to ''remote_node'" $ write sys$output "''error_message'" $ write sys$output "" $ exit $! $ err_start_server: $! $ write sys$output "" $ write sys$output - "%RMT-F-NOSTART, Error starting remote tape server on ''remote_node'" $ write sys$output "" $ write netline "**DONE**" $ close netline $ exit $!********************************************************************* $! $! Gory details : $! $! This procedure performs the following tasks in cooperation with a $! network object on the remote node : $! $! o Prompts the user for the name of the remote node, and the name of $! the remote tape device. $! o Opens a network link to network object #142 on the node with the $! tape drive. Object #142 is just a command procedure that does $! various things, described below. $! o Waits for the command procedure on the remote side to take the steps $! necessary to put ZTAn: on-line. $! o Spawns a subprocess to allow the user to use ZTAn: as he pleases. When $! the user logs out of the subprocess control is returned to this $! procedure to allow things to be cleaned up neatly (hopefully). $! o Cleanup involves dismounting ZTAn if necessary, $FORCEX'ing the process $! which is running the ZT2 image, telling the other side that we are $! all done, and then closing the network link. $! $! Network object #142 is a command procedure on the remote that performs $! the following tasks : $! $! o Opens a channel on SYS$NET to communicate with this procedure $! o Checks on the availability of the requested device, i.e., does it exist, $! and is it unallocated? Bail out if not. $! o MOUNTs the tape $! o Runs the server image ZTNS2 as a subprocess. ZTNS2 starts up a network $! object back on this side that fires up the ZT2 image. When all of this $! happens, ZTAn: magically comes on-line (hopefully)! $! o Now the procedure issues a READ on SYS$NET, waiting for a control string $! that indicates that the other side is done with the drive. It also can $! detect whether the other side has closed the network link abnormally. $! o Dismounts the tape, and closes the network link $! o Logs out, thus killing the subprocess running ZTNS2.