Iterate with files in Openvms DCL

1.3k views Asked by At

I have this file input.text with say 20 lines. (Although I would like to be able to use any number of lines)

So I want to open the said file and use each string as though it was a parameter for another command.

This other command would take each parameter perform it's function and then write the output to another file itself.

How can I accomplish the intended?

1

There are 1 answers

1
DennisP On

Here is an example DCL command file that reads INPUT.TXT and uses the lines found as parameters to a DIR command that outputs to a file called DIROUT.TXT:

$! Read file using results as DIR command parameters...
$ file1="INPUT.TXT"
$ file2="DIROUT.TXT"
$ open/read chnl1 'file1'
$ on control_y then goto done_loop
$ on error then goto done_loop
$read_loop:
$ read/end_of_file=done_loop chnl1 opt1
$ write sys$output ">>> Sending DIR ",opt1," output to ''file2'..."
$ dir/out='file2' 'opt1'
$ goto read_loop
$done_loop:
$ close chnl1
$ write sys$output "Finished..."
$ EXIT

You should be able to adapt this to your requirements.