Module 5 — DCL Scripting & Automation
Overview
This module covers DCL scripting fundamentals, including symbols, lexical functions, command procedures, flow control, batch processing, and error handling. You’ll learn how to automate routine tasks and build reliable operational scripts.
Exam: Multiple‑Choice Questions
1. Which symbol type is local to a command procedure?
2. Which command executes a DCL command procedure?
3. Which lexical function returns the current process name?
4. Which command submits a command procedure to a batch queue?
5. Which DCL feature allows you to detect and handle errors within a script?
Hands‑On Exercises
Exercise 1 — Create Basic Symbols
- Create a local symbol:
MYVAR = "Hello" - Display it:
SHOW SYMBOL MYVAR - Create a global symbol:
MYGLOBAL == "World" - Display it:
SHOW SYMBOL/GLOBAL MYGLOBAL
Exercise 2 — Write a Simple Command Procedure
- Create a file named
HELLO.COMcontaining:
$ WRITE SYS$OUTPUT “Hello from DCL!” $ EXIT
Code
- Execute it:
@HELLO
Exercise 3 — Use Lexical Functions
- Display the current process name:
WRITE SYS$OUTPUT F$PROCESS() - Display the current default directory:
WRITE SYS$OUTPUT F$ENVIRONMENT("DEFAULT")
Exercise 4 — Add Flow Control
Create a script:
$ IF F$SEARCH(“TEST.DAT”) .EQS. “” THEN GOTO NOTFOUND $ WRITE SYS$OUTPUT “File exists.” $ EXIT $ NOTFOUND: $ WRITE SYS$OUTPUT “File not found.” $ EXIT
Code
Run it and test both conditions.
Exercise 5 — Submit a Batch Job
- Create a batch script:
$ WRITE SYS$OUTPUT “Batch job running…” $ EXIT
Code
- Submit it:
SUBMIT BATCHJOB.COM - Check queue status:
SHOW QUEUE/BATCH
Scenario‑Based Troubleshooting Challenges
Scenario 1 — Script Fails Silently
A DCL script exits without printing expected output.
Expected approach:
- Check
$STATUS - Add
SET VERIFY - Add
SET NOON - Check symbol scoping
Scenario 2 — Batch Job Never Starts
A submitted batch job remains in “Holding” state.
Expected approach:
- Check queue status
- Check queue limits
- Check job quotas
- Check batch queue startup
Scenario 3 — Lexical Function Returns Unexpected Value
A script using F$GETJPI returns blanks.
Expected approach:
- Verify correct item code
- Check privileges
- Check quoting and syntax
Answer Key
The answer key for this module is located at:
answers/module5-answers.md