HP OpenVMS Systems

ask the wizard
Content starts here

Seeking DCL Programming Tips?

» close window

The Question is:

I frequently write scripts that do this:
$ sho dev d /out=devices.tmp
$ open/read infile devices.tmp
$    read/end=DONE x y
$    .
$    goto LOOP
$    close x
$    delete devices.tmp;
but it would be much more elegant if I didn't have to create this temporary
 file. Is it possible to use a pipe command to do this?  Something like:
$ pipe show device d | (some code which would loop through the returned lines
 one by one and do whatever processing is necessary)
I have tried working with this but have not been able to make the loop business
 work. I have tried using multiple dcl statements separated by semicolons (and
 obligatory spaces), but the command saying to GOTO LABEL is ignored.
Maybe this just isn't possible, but I wanted to get the "final answer" before
 abandoning this route.

The Answer is :

  The DCL lexical function f$device avoids creating a temporary file.
  Please see the available help text ($ HELP LEXICAL F$DEVICE) and the
  OpenVMS User's Guide for details here, as well as books available on
  the topic of DCL programming, and consider the following example:
    $ START:
    $     DEVICE_NAME = F$DEVICE("*0:","DISK","RA60")
    $     GOTO START
  Direct parsing of command output is generally not recommended and is
  generally not considered supported -- displays can and do change.

answer written or last revised on ( 24-NOV-2003 )

» close window