Many of the operations that you perform on disk and tape media
are routine. It is worthwhile to identify those routine tasks and
design command procedures to assist you in performing them. To
become familiar with the syntax used to design and execute command
procedures, refer to the OpenVMS User's Manual
.
You might, for example, want to design command procedures
to set up private disk and tape volumes. The command procedure examples
in this section, although general in nature, can serve as guiding
strategies for you. You can tailor these command procedures to meet
the needs of your own setup tasks.
Sample
Command Procedure for Setting Up Disk Volumes The command procedure
in this section allocates, initializes, and mounts a disk volume.
Follow these steps:
Use a text editor
to create a file named SETUP.COM.
Enter the following command procedure, which, when
executed, allocates and mounts a disk:
$ ! Place a disk in the drive
$ IF P1 .EQS. "" THEN INQUIRE P1 "enter device name"
$ IF P2 .EQS. "" THEN INQUIRE P2 "enter volume label"
$ IF P3 .EQS. "" THEN INQUIRE P3 "enter logical name"
$ ALLOCATE 'P1'
$ MOUNT 'P1' 'P2' 'P3'
This command procedure, although very simple, accomplishes
the task of allocating and mounting a disk each time you execute
it. It prompts you for the device name, volume label, and logical
name of the disk device that you want to allocate and mount. By
assigning logical names to your disks, you can use this command
procedure to allocate and mount devices repeatedly. You can take further advantage of the power of a command procedure
by including a few additional tasks as well. For example, you might
design the SETUP.COM command procedure to deallocate and dismount the
disk. The command procedure example used to set up a magnetic tape
(described in
Sample Command Procedure for Setting Up Tape Volumes)
takes advantage of some of these options.
To execute the SETUP.COM command procedure, enter
the following command:
$ @SETUP
Sample
Command Procedure for Setting Up Tape Volumes The command procedure
shown in
Command Procedure to Set Up Tape Volumes, which
is more complex and detailed than the previous example, is designed
to set up a magnetic tape for processing. The ALLOCATE and MOUNT/FOREIGN commands
are included in this command procedure. Using a text editor, construct
the command procedure as shown in the example.
Example 1 Command Procedure to Set Up Tape Volumes
$ ! First mount the tape on the drive
$ ON CONTROL_Y THEN GOTO EXIT
$ ON ERROR THEN GOTO EXIT
$ WRITE SYS$OUTPUT "Welcome to FETCH."
$ WRITE SYS$OUTPUT " "
$ L1: INQUIRE/NOPUNC PHYS "Have you placed the volume in the drive? "
$ IF .NOT. PHYS THEN GOTO L1
$ INQUIRE/NOPUNC DRIVE "Which drive is the volume mounted on? "
$ DRIVE = DRIVE - ":"
$ ALLOCATE 'DRIVE'
$ MOUNT/FOREIGN 'DRIVE'
$ ON ERROR THEN GOTO COMMAND_LOOP
$ !
$ COMMAND_LOOP: INQUIRE/NOPUNC OPTION "FETCH> "
$ IF OPTION .EQS. "DIR" THEN GOTO DIR
$ IF OPTION .EQS. "EXIT" THEN GOTO EXIT
$ IF OPTION .EQS. "FETCH" THEN GOTO FETCH
$ IF OPTION .EQS. "HELP" THEN GOTO HELP
$ IF OPTION .EQS. "LIST" THEN GOTO LIST
$ GOTO COMMAND_LOOP
$ !
$ DIR: INQUIRE SPEC "Filespec"$ DIR 'SPEC'
$ GOTO COMMAND_LOOP
$ HELP:
$ WRITE SYS$OUTPUT "Enter any of the following commands at the prompt:"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "DIR (To search for a file)"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "EXIT (To exit this program)"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "FETCH (To perform a BACKUP RESTORE operation)"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "HELP (To read this text)"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "LIST (To perform a BACKUP LIST operation)"
$ GOTO COMMAND_LOOP
$ !
$ FETCH: INQUIRE FILE "Filespec"
$ INQUIRE SAVESET "Save set name"
$ LINE := BACKUP/LOG 'DRIVE':'SAVESET'/SELECT='FILE'
$ INQUIRE EXCLUDE "Enter any filespecs you want excluded"
$ IF EXCLUDE .EQS. "" THEN GOTO L2
$ LINE := 'LINE'/EXCLUDE=('EXCLUDE')
$ !
$ L2: INQUIRE/NOPUNC TO "Where do you want the file(s)? (RET for current directory)"
$ IF TO .EQS. "" THEN GOTO REPLACE
$ LINE := 'LINE' 'TO'
$ GOTO L3
$ REPLACE: LINE := 'LINE' []
$ !
$ L3: INQUIRE/NOPUNC NEW "Create a new version if file already exists? "
$ IF .NOT. NEW THEN GOTO NOT
$ LINE := 'LINE'/NEW_VERSION
$ !
$ NOT: LINE := 'LINE'/OWNER_UIC=ORIGINAL
$ LINE
$ GOTO COMMAND_LOOP
$ !
$ LIST: INQUIRE SPEC "Filespec"
$ INQUIRE SAVESET "Save set name"
$ INQUIRE/NOPUNC OUTPUT "What do you want to call the list file? (RET for SYS$OUTPUT )"
$ IF OUTPUT .EQS. "" THEN GOTO NOOUT
$ LINE := BACKUP/LIST='OUTPUT' 'DRIVE':'SAVESET'/SELECT=('SPEC')
$ GOTO L4
$ NOOUT: LINE := BACKUP/LIST 'DRIVE':'SAVESET'/SELECT=('SPEC')
$ !
$ L4: INQUIRE EXCLUDE "Enter any filespecs you want excluded"
$ IF EXCLUDE .EQS. "" THEN GOT L5
$ LINE := 'LINE'/EXCLUDE=('EXCLUDE')
$ !
$ L5: LINE
$ GOTO COMMAND_LOOP
$ !
$ EXIT:
$ DISMOUNT 'DRIVE'
$ DEALLOCATE 'DRIVE'
Assuming this command procedure is in a file named FETCH.COM,
execute the command procedure by entering the following command:
$ @FETCH
In addition to allocating and mounting functions, as in the
previous example, FETCH.COM prompts you for input. For example,
it specifically asks you if the tape is on the drive. Also note
that FETCH.COM does a BACKUP restore operation. It prompts you for
specific options on the restore operation. Finally, FETCH.COM explicitly
dismounts your magnetic tape volume and deallocates the drive after
your task completes.