Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi there. I'm having a small problem with trying to write a script that will perform the following 3 items..
1) Search recursively from [000000] directory and all subfolders for all ".EXE" files..
2) As it finds each ".EXE" file place the full filename syntax of the executeable into a "text" file called "report.dat" (Eg; if it found "dummyfile.exe" then write to the text file: GXPROSYS:[RUNDIR]DUMMYFILE.EXE)
3) Not sure if an "end of file" marker is required at the end of the "text" file as I have another script that will then read in this "text" file..
Below is what I've come up with...
SET DEF [000000]
DIR [...]*.COM /COLUMNS=1 /OUTPUT=REPORT.DATThis finds all the ".EXE" files and places the output into "REPORT.DAT" except it looks like this (below)
Directory GXPROSYS:[000000.MRPT.PRIVATE]PROGRAM1.EXE
PROGRAM2.EXE
PROGRAM3.EXETotal of 3 files.
I would really like it to look like this...GXPROSYS:[000000.MRPT.PRIVATE]PROGRAM1.EXE
GXPROSYS:[000000.MRPT.PRIVATE]PROGRAM2.EXE
GXPROSYS:[000000.MRPT.PRIVATE]PROGRAM3.EXEHas anyone got any ideas ?? Not sure if I should be using F$SEARCH or doing some sort of LOOP.. Ie; as it finds the ".EXE" append to the end of the ".DAT" file.. All comments appreciated..
Thankyou in advance :)
Stephen McBride

Stephen,
Actually, what you are looking for is fairly simple.
If I understand you correctly, you are seeking the same basic functionality that is used to list files by the DIRECTORY command. For example, the DIRECTORY command to list all executable binary files on a disk would be DIRECTORY devicename:[000000...]*.EXE. The "000000" is a reference to the MFD (Master File Directory) which is the root of the directory structure on a file-structured volume.
The iterative search functionality is actually a part of RMS, the Record Management System. From DCL, it can be accessed using the F$SEARCH lexical function, as illustrated by the following small code segment that iteratively scans for all executable files on volume DKA200:
$ TOP: FILENAME = F$SEARCH("DKA200:[000000...]*.EXE")
$ IF F$LENGTH(FILENAME) .EQ. 0 THEN EXIT
$ WRITE SYS$OUTPUT FILENAME
$ GOTO TOPWhile it is guaranteed that every executable file will show up at least once, it is also possible to see files more than once, because of the possibility of alias entries for directories.
When the search is complete, the result of FF$SEARCH will be an empty string.
Since you get the filenames back one filename at a time, there is a good chance that you will not need an intermediate file.
You may also find my presentation on DCL lexical functions from the 1995 San Francisco DECUS User's symposium, "DCL Lexicals: OpenVMS Jujitsu", useful. The slides from that session can be found at:
http://www.rlgsc.com/decus/usf95/index.html
- Bob Gezelter, http://www.rlgsc.com

Bob,
Thankyou for your timely response. Your example code nailed my problem right on the head (required some slight ammendments but otherwise perfect for the problem at hand)
Kinds regards
Stephen McBride

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |