Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Directory with Versions almost to the limit

Status
Not open for further replies.

meny21

IS-IT--Management
Oct 4, 2002
101
MX
Hi Guys!

As you know in Open VMS when you create another file with the same name this one is a new version, and when you come to 32767 versions the system reach to the last one and some process can be blocked.

Does anyone knows how can I trace with a DIR or some other command the files that are coming for example from 32700 - 32767 versions?

This is to prevent and purge with previous time the files in order that everything will be correctly

Thanks for any information

MR
 
meny21,

You could do a $ DIRECTORY [*...]*.*;32767 on each drive (or write a command file using the F$SEARCH lexical function; see my presentation on DCL lexicals at
There is no convenient syntax for a band of version numbers, but it is easy enough to either:
- do repetitive DIRECTORY or F$SEARCH commands with explicit version numbers
- use a wildcard version number "*", parse the resulting file names, checking for versions in the range that concerns you.

Robert "Bob" Gezelter,
 
Hi Rob,

I know what you mean, you understand my point....

I tried the first option looking for a explicit version and runs ok.

But the second one:
- use a wildcard version number "*", parse the resulting file names, checking for versions in the range that concerns you.

How can I put this command with Directory in order to see a Range of versions?

Thanks again

Meny21
 
Meny21,

You need to write a command file. VMS Command Files serve the same functions as scripts on some other operating systems. You will not need to use the DIRECTORY command, you will use the F$SEARCH lexical function to iterate through the filenames, and the F$PARSE lexical function to extract the version number as a standalone string. You can then check it in any way that you wish.

Robert "Bob" Gezelter,
 
Meny21...

Here's a couple of command procedures I wrote quite some years ago - perhaps not "optimised code", but it does exactly what I need it to... I have taken these everywhere I've worked to manage just the problem you are describing. NOTE: these are two seperate command procedures - the GET_DISK_LIST.COM file is one I call from many other programs... either edit the location to match where you save it to on your system, or hack away and compress the two procedures into a single file. The main procedure CHECK_FILE_VERSIONS.COM can either be run interactively (reports to sys$output), or (as I usually do) add it to my periodic housekeeping routines and then mail the report to myself...

As usual, NO GUARANTEE ot WARRANTY etc with this program - I post it merely to show you how to manage the file limitation - you will need to massage it to get it running on your system! There is no automatic "fixing" of the problem (any files reported you should be investigating manually anyway), but this will alert you to files nearing the limitation. Usually I look for anything at 20,000 versions or more... then kick the developers and tell them to use unique file names instead of depending on versioning...

Hope it helps!

Main Procedure:

$GOTO CHECK_IF_CALLED
$!.......................................................................
$! private_UTILS_NODE:CHECK_FILE_VERSIONS.COM
$!
$! Purpose :-
$!
$! Checks the highest version of a file, and reports if it exceeds
$! a predetermined threshold.
$!
$!
$! Dependancies:-
$!
$! Program private_UTILS_NODE:GET_DISK_LIST.COM must exist.
$!
$!
$! Inputs :-
$!
$! Nil.
$!
$!
$! Outputs :-
$!
$! Mailed report file - see value of 'workfile'.
$!
$!
$! Modifications.
$!---------------
$!
$! Hugh Samson 28/8/98 Implemented.
$!
$!.......................................................................
$Check_If_Called:
$ ! This routine is usually called from DISK_STATUS.COM, which uses
$ ! the file 'reportfile' for output.
$ If f$trnlnm("REPORTFILE") .nes. ""
$ Then
$ say == "WRITE REPORTFILE"
$ Else
$ say == "WRITE SYS$OUTPUT"
$ Endif
$
$Error_Handling:
$ set NOon
$
$Initialize:
$ reqdisk = "''p1'"
$ cur_disk = ""
$ max_ver = 20000
$ ttl_files == 0
$ pid = f$getjpi("","pid")
$ node = f$getsyi("NODENAME")
$
$!.......................................................................
$Mainline:
$
$ If (reqdisk.eqs."").or.(f$edit("''reqdisk'","COLLAPSE,UPCASE").eqs."ALL")
$ Then
$ cur_disk = "ALL"
$ Else
$ cur_disk = "''reqdisk'" - "$1$" - ":" - "_"
$ cur_disk = "$1$''cur_disk':"
$ Endif
$
$ say ""
$ Say " >> Reporting on versions greater than ''max_ver' <<"
$
$ Call Get_Disk_List "''cur_disk'"
$
$ EXIT
$
$!.......................................................................
$Get_File_List: SUBROUTINE
$
$ disk = "''p1'"
$ tmp_files = 0
$
$ File_Loop:
$ file=f$search("''disk'[*...]*.*;")
$ If file .eqs. ""
$ Then
$ if tmp_files .gt. 0
$ then
$ say " "
$ say " >> ''tmp_files' exceed on this disk."
$ else
$ say " "
$ say " All file versions within specs."
$ endif
$ EXIT
$ Endif
$
$ file_ver = f$parse("''file'",,,"version")
$ file_ver = "''file_ver'" - ";"
$ file_ver = f$integer(file_ver)
$
$ If 'file_ver .lt. 'max_ver
$ Then
$ goto file_loop
$ Else
$ tmp_files = tmp_files + 1
$ ttl_files == ttl_files + 1
$ say " --> ''file'"
$ goto file_loop
$ Endif
$ ENDSUBROUTINE
$!.......................................................................
$Get_Disk_List: SUBROUTINE
$
$ If p1 .eqs. "ALL"
$ Then
$ @private_utils_node:get_disk_list
$ count = 1
$ disk_loop:
$ disk = disk_'count'_name
$ Call get_file_list "''disk'"
$ count = count + 1
$ if count .eq. disk_ttl then exit
$ goto disk_loop
$ Else
$ Call get_file_list "''cur_disk'"
$ Endif
$
$ ENDSUBROUTINE
$!.......................................................................


Procedure 2:

$GOTO Startup
$!-----------------------------------------------------------------------------
$! GET_DISK_LIST.COM
$!
$!<>
$! Purpose:
$!
$! This program will obtain a list of disk devices from the system, and
$! define the disk name into global symbols. INFOSERVER and CD-ROM disk
$! units are NOT defined. No handling is provded for software based STRIPE
$! disks. Shadow set MASTERs are listed, shadow set MEMBERS are not.
$!
$!<>
$! Dependancies:
$!
$! None.
$!
$!<>
$! Input/Output:
$!
$! A number symbols are defined :-
$!
$! DISK_TTL. The total number of disk symbols that have been
$! defined.
$!
$! DISK_'nbr'_NAME The name of the disk where 'nbr' relates to the
$! device counter specified. E.G. DISK_1_NAME may
$! translate to "_KWV001$DKB400:"
$!
$!<>
$! Modifications :
$!
$! Hugh Samson ("PiC" @ private) 19/8/1998 Implemented.
$!
$!
$!
$!-----------------------------------------------------------------------------
$!
$Startup:
$
$Get_Disk_List:
$
$ disk_nbr == "" ! Disk sequence nbr
$ disk_ttl == "" ! Total disk count
$
$ Disk_Loop:
$
$ dev = f$device("*","DISK",)
$
$ If "''dev'" .eqs. "" then goto end_disk_loop
$
$ ! Check if shadow set member. (Only want DSA devices)
$ If f$getdvi("''dev'","SHDW_MEMBER") then goto disk_loop
$
$ ! Check if disk is mounted.
$ If .not. f$getdvi("''dev'","MNT") then goto disk_loop
$
$ ! Check if part of SOFTWARE stripeset.
$ If f$getdvi("''dev'","FREEBLOCKS") .eqs. "2076" then -
goto disk_loop
$
$ ! Check if info-server disk.
$ If (f$extract(0,3,dev) .eqs. "DAD") .or. -
(f$extract(0,4,dev) .eqs. "_DAD") -
then goto disk_loop
$
$ ! Check if write-locked (privately mounted).
$ If f$getdvi("''dev'","WCK") then goto disk_loop
$
$ ! Check if attached CD drive.
$ If f$getdvi("''dev'","DEVTYPE") .eqs. "72" then -
goto disk_loop
$
$ disk_nbr == disk_nbr + 1
$ disk_ttl == disk_ttl + 1
$ disk_'disk_nbr'_name == "''dev'"
$
$ goto disk_loop
$
$ End_Disk_Loop:
$
$ If "''disk_nbr'" .nes. "" then dele/sym/glo disk_nbr
$
$ EXIT
$
$!-----------------------------------------------------------------------------
$!


Hope this helps - feel free to laugh if you find the code less than "optimal"

:)

Hugh.
 
It's lovely, brings me back, wish I'd kept all my scripts :-(

Perl would be a breeze for this.

How about a recursive directory listing to a file, and then use something like perl to parse the file?

If someone could remind me what a VMS file listing looks like, preferably a line per file or blank ...

I'm not sure a purge will be enough here ... it's still going to maintain the version numbers.

You're possibly going to have to create a temp directory, copy the files in order into the sub directory with specific version numbers (ie, 1,2,3,...), clean up the working directory for that file, and move the temp files into the working directory, or at the very least a recursive rename from the lowest version to 1, next to 2, etc, etc, the latest version of the file could be troublesome because of a file lock though

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top