OpenVMS User Manual Notes
This blog is the summay of major DCL syntax/command/example (when I am a green hand to the OpenVMS and DCL).
OpenVMS is an interactive virtual memory operating system (Mainly for high availablity server, https://en.wikipedia.org/wiki/OpenVMS).
The DIGITAL Command Language (DCL) is a set of English-like instructions that tell the operating system to perform specific operations. DCL provides you with over 200 commands and functions to use in communicating with the operating system to accomplish computing tasks. DCL commands let you do the following:
• Get information about the system
• Work with files
• Work with disks, magnetic tapes, and other devices
• Modify your work environment
• Develop and execute programs
• Provide security and ensure that resources are used efficiently
Symbol
Assignment statement (= or ==)
String assignment (:= or :==)
Local symbols are accessible from the current command level and from
command procedures executed from the current command level.
$ SS =
"SHOW SYMBOL"
$ DB :=
DIRECTORY ACCOUNTS:[BOLIVAR]
Global symbols are accessible at all command levels.
$ DC ==
"DIRECTORY/SIZE=ALL DISK1:[JONES.TAX]MONEY.LIS"
$ READY :==
PRINT/CONFIRM/QUEUE=AKI$LN03/NOTIFY/RESTART
Symbol Abbreviation
$ PR*INT = "PRINT/CONFIRM/QUEUE=AKI$LN03/NOTIFY/RESTART"
Defining Foreign Commands A symbol that runs an image is referred to as a foreign command
$ PRINTALL :== $[ACCOUNTS]PRINTALL
Symbol Substitution
$ NAME = "MYFILE"
$ TYPE = ".DAT"
$ PRINT 'NAME''TYPE'
Deleting Symbols
$ DELETE/SYMBOL/GLOBAL TEMP
Displaying Symbols
$ SHOW SYMBOL PR
PR*INT = "PRINT/CONFIRM/COPIES=2/QUEUE=DOC$LN03/NOTIFY/RESTART"
$ SHOW SYMBOL TOTAL
TOTAL = 4 Hex = 00000004 Octal = 00000000004
Using Symbols with Other Symbols
$ COUNT = 3
$ TOTAL = COUNT + 1 //total
= 4
Symbol Concatenation
$ DAY1 = "Saturday, "
$ DAY2 = "Sunday"
$ WEEKEND = DAY1 + DAY2
$ SHOW SYMBOL WEEKEND
WEEKEND = "Saturday,
Sunday"
Including Symbols in String Assignments
$ COUNT = 3
$ BARK := P'COUNT' //bark =
“P3”
$ A = ""
$ B = 2
$ C = A + B
$ SHOW SYMBOL C
C = 2 Hex = 00000002 Octal = 00000000002
Defining Character Strings "" as quotation , +
-_ to continue string over two lines
$ PROMPT = "Type ""YES"" or ""NO"""
$ SHOW SYMBOL PROMPT
PROMPT = "Type "YES" or "NO""
$ HEAD = "MONTHLY REPORT FOR" + " DECEMBER
1999"
$ SHOW SYMBOL HEAD
HEAD = "MONTHLY REPORT FOR DECEMBER 1999"
Character String Operations
$ COLOR = "light brown"
$ WEIGHT = "30 lbs."
$ DOG2 = "No tag, " + COLOR +
", " +
WEIGHT
$ SHOW SYMBOL DOG2
DOG2 = "No tag, light brown, 30 lbs."
$ DOG2 = DOG2 -
", 30 lbs."
$ SHOW SYMBOL DOG2
DOG2 = "No tag, light brown"
Comparing Character Strings
Comparison |
Operator |
Description |
Equal to |
.EQS. |
Compares one character string toanother for equality. |
Greater than or equal to |
.GES. |
Compares one character string |
Greater than |
.GTS. |
Compares one character string to |
Less than or equal to |
.LES. |
Compares one character string |
Less than |
.LTS. |
Compares one character string to |
Not equal |
.NES. |
Compares one character string to |
$ TEST_NAME
= LAST_NAME .EQS. "Hill"
$ SHOW SYMBOL TEST_NAME
TEST_NAME = 0 …
Replacing Substrings symbol-name[offset,size]
:= replacement-string
$ A := PACKRAT
$ A[0,4] := MUSK
$ SHOW SYMBOL A
A = "MUSKRAT"
Specifying Numbers
$ BALANCE = -%X3B85
$ SHOW SYMBOL BALANCE
BALANCE = -15237 Hex = FFFFC47B Octal = 37777742173
$ B = "-9" + 23
$ show sym B
B = 14 Hex = 0000000E Octal = 00000000016
Comparing Numbers
Comparison |
Operator |
Description |
Equal to |
.EQ. |
Compares one number to |
Greater than or equal to |
.GE. |
Compares one number to |
Greater than |
.GT. |
Compares one number to |
Less than or equal to |
.LE. |
Compares one number to |
Less than |
.LT. |
Compares one number to |
Not
equal to |
.NE.
|
Compares
one number to |
$ TEST_BALANCE = BALANCE .EQ. -15237
$ SHOW SYMBOL TEST_BALANCE
TEST_BALANCE = 1 …
Performing Numeric Overlays symbol-name[bit-position,size]
= replacement
$ BELL = 7
$ BELL[5,1] = 1
$ SHOW SYMBOL BELL
BELL = 39 Hex = 00000027 Octal = 00000000047
Logical Operations
$ STATUS = 1
$ IF STATUS THEN DOG_COUNT = 13
$ STATUS = "TRUE"
$ IF STATUS THEN DOG_COUNT = 13
Using Values Returned by Lexical
Functions
$ LEN = F$LENGTH(F$DIRECTORY())
$ SHOW SYMBOL LEN
LEN = 8 Hex = 00000008 Octal = 00000000010
Forced Symbol Substitution
1.
Apostrophe (’)
2.
Ampersand (&)
$ T = "TYPE ''B'"
$ P1 = "FRED.DAT"
$ COUNT = 1
$ TYPE &P'COUNT'
Command Procedure
LOGIN.COM in your top-level directory will run whenever
you log in
$ PRINT LAB.DAT -
/AFTER=17:00 -
/COPIES=20 -
/NAME="COMGUIDE"
Input from terminal
The INQUIRE command prompts for a value,
reads the value from the terminal, and assigns the value to a symbol.
$
INQUIRE COMMAND-
"Enter command (DELETE, DIRECTORY, PRINT, PURGE, TYPE)"
Debugging Command Procedures
SET VERIFY
SET NOVERIFY
SET PREFIX
Executing Command Procedures @command
$ INQUIRE TIME "What is the current
time in hh:mm format?"
$ @GETDATE [JONES.COM]GETDATE.COM
You can use the TYPE command to execute
command procedures in the top-level directory of another account on a remote
node.
$ TYPE nodename"username password"::"TASK=command_procedure"
Methods of Exiting
• Place an EXIT command in the command procedure
• Place a STOP command in the command procedure
• Enter Ctrl/Y during the execution of the program
$ ON WARNING THEN EXIT
$ ON ERROR THEN GOTO ERR1
Detecting Errors in Command Procedures
Using Condition Codes
$ SHOW SYMBOL $STATUS
$STATUS = " %X109110A2"
$ WRITE SYS$OUTPUT F$MESSAGE(%X109110A2)
%CREATE-E-OPENOUT, error opening !AS as output
In the following example, SYS$OUTPUT is
defined as a null device (NL:).
$ DEFINE/USER_MODE SYS$OUTPUT NL:
Redirect output from the SHOW TIME
command to the file TIME.DAT
$ DEFINE SYS$OUTPUT TIME.DAT
$ SHOW TIME
$ DEASSIGN SYS$OUTPUT
Redefining SYS$ERROR
$ DEFINE/USER_MODE SYS$ERROR NL:
Using the OPEN Command
$ OPEN/READ INFILE DISK4:[MURPHY]STATS.DAT
$ OPEN/WRITE OUTFILE DISK4:[MURPHY]DATA.OUT
Search File Name
$ INQUIRE FILE "File" ! Prompt the user for a file name
$ IF F$SEARCH (FILE) .NES. "" ! Make sure the file name is unique
Using IF THEN ELSE ENDIF Command Blocks
$ IF condition
$ THEN @command_procedure
$ ELSE command
$ command
$ ENDIF
Using the GOSUB and RETURN Commands
$ GOSUB TEST1
$ TEST1:
$ WRITE SYS$OUTPUT "This is GOSUB
level 1."
$ RETURN %X1
Beginning and Ending Subroutines
$ CALL BAR
$ MAIN: SUBROUTINE
$ BAR: SUBROUTINE
$ ENDSUBROUTINE
$ ENDSUBROUTINE
Writing Loops
$ NUM = 1 !
Set counter
$LOOP: !
Begin loop
$ INQUIRE FIL'NUM' "File" !
Get file name
$ NUM = NUM + 1 !
Update counter
$ IF NUM .LT. 11 THEN GOTO LOOP !
Test for termination
$END_LOOP: !
End loop
Loop for a sequence of values, use the
F$ELEMENT
$ FILE_LIST = "1,2,3,A,B,C"
$ INDEX = 0
$PROCESS:
$ NUM = F$ELEMENT(INDEX,",",FILE_LIST)
$ IF NUM .EQS. "," THEN GOTO END_LOOP
$ GOTO PROCESS
$END_LOOP:
command-sequence2 executes if and only
if command-sequence1 succeeds
PIPE command-sequence1 && command-sequence2
command-sequence2 executes if and only
if command-sequence1 fails
PIPE command-sequence1 || command-sequence2
The pipe connects the SYS$OUTPUT of one
pipeline-segment command to the SYS$INPUT of the next command
PIPE pipeline-segment-command | pipeline-segment-command [|…]
Use logical SYS$PIPE obtain data from
the pipe inside a command procedure
$ ! TEE.COM - command procedure to display/log data flowing
through
$ ! a pipeline
$ OPEN/WRITE tee_file 'P1'
$ LOOP:
$ READ/END_OF_FILE=EXIT SYS$PIPE LINE
$ WRITE SYS$OUTPUT LINE ! Send it out to the pipeline
$ WRITE tee_file LINE ! Log output to the log file
$ GOTO LOOP
$ EXIT:
$ CLOSE tee_file
$ EXIT
To use TEE.COM, enter the following PIPE
command:
$ PIPE SHOW SYSTEM | @TEE showsys.log | SEARCH SYS$INPUT LEF
Using the PIPE Command for Subshell
Execution
PIPE (
command-sequence [separator command-sequence]... )
Using the PIPE Command for Background
Execution
PIPE command-sequence [ separator command-sequence]... &
To redirect SYS$INPUT:
PIPE command-sequence < redirected-input-file
To redirect SYS$OUTPUT:
PIPE command-sequence > redirected-output-file
To redirect SYS$ERROR:
PIPE command-sequence 2> redirected-error-file
Changing Verification Settings
$ ! Save each verification state
$ SAVE_VERIFY_IMAGE = F$ENVIRONMENT("VERIFY_IMAGE")
$ SAVE_VERIFY_PROCEDURE = F$VERIFY(0)
$ ! Restore original verification states
$ SAVE_VERIFY_IMAGE = F$VERIFY(SAVE_VERIFY_PROCEDURE,-
SAVE_VERIFY_IMAGE)
Subprocess Context
Because copying logical names and symbols to a subprocess can be
time-consuming (a few seconds), you may want to use the /NOLOGICAL_NAMES and /NOSYMBOL qualifiers
to the SPAWN command unless you plan to use the logical names or symbols in the
subprocess. If you use subprocesses frequently, the ATTACH command provides the most efficient
way to enter and exit a subprocess. This method allows you to transfer control
quickly between the parent process and subprocess rather than repeatedly
waiting for the system to create a new subprocess for you.
Submitting Batch Jobs
$ SUBMIT JOB1
Job JOB1 (queue SYS$BATCH, entry 651, started on SYS$BATCH)
Saving Log Files
$ SUBMIT/LOG_FILE=DISK2:[JONES.RESULTS]/NOPRINTER -
_$ DISK2:[JONES.RESULTS]UPDATE
Comments
Post a Comment