I was hoping someone may have already written a DCL procedure for this
problem. I have searched but could not find anything.
I would like to reset the version number on a file once it reaches or
approaches 32767.
e.g.
If I had 3 files
file.dat;32767
file.dat;32766
file.dat;32765
I would like to run the procedure and set the version number on the
files as follows :
file.dat;3
file.dat;2
file.dat;1
Hoping someone may be able to help
Thanks,
> I was hoping someone may have already written a DCL procedure for this
> problem. I have searched but could not find anything.
>
> I would like to reset the version number on a file once it reaches or
> approaches 32767.
> [...]
I have some (probably rough) code in my TCPIP$SMTP_RECV_RUN.COM to
deal with the TCPIP$SMTP_RECV_RUN.LOG files. I've been meaning to
extract and generalize it a bit, especially since I discovered that
SYS$SYSDEVICE:[TCPIP$SSH]TCPIP$SSH_RUN.LOG is also climbing out of
sight. I use a lock file near the file to be purged/reversioned (and
another trick or two) to avoid having two jobs collide. If you don't
get any better offers, let me know, and I can probably get to work and
beat it into better (less embarassing) shape. (It may be flawed, but it
has been working acceptably for some months now on the SMTP logs. At
the rate I get junk e-mail connections, it probably resets the versions
every few days. Of course, its proper operation could be more by luck
than design.)
It would be nice, if HP plans to continue to cause this problem, if
they also supplied a good solution for it.
------------------------------------------------------------------------
Steven M. Schweda sms@antinode-org
382 South Warwick Street (+1) 651-699-9818
Saint Paul MN 55105-2547
$ RENAME FILE>DAT;32765 ;1
$ RENAME FILE.DAT;32766 ;2
$ REMA<E FILE.DAT;32767 ;3
Thanks Steven,
If you would be able to post your procedure it would be much
appreciated.
Thanks Russell,
I know about the rename, I gave an example of 3 files but I am talking
more about 100's which I would like to rename and keep in version
order through a daily/weekly submitted procedure.
Although it does not care for locked files, I'm using a procedure posted
(here ?) 10 years ago:
http://wwwvms.mppmu.mpg.de/vms$common/sysmgr/FIND_HIGH_VERSIONS.COM
--
Joseph Huber - http://www.huber-joseph.de
This procedure requires that you specify the number of versions to save,
but it will give you a start on saving all versions...
$! See bottom of file for comments
$ if f$edit (p1,"collapse,uncomment") .eqs. ""
$ then
$ write sys$output "P1 must specify a filename"
$ exit 44
$ endif
$ if f$edit (p2,"collapse,uncomment") .eqs. ""
$ then
$ p2 = 1
$ endif
$ log_file = f$search (p1)
$ if log_file .nes. ""
$ then
$ version = f$parse (log_file,,,"version") - ";"
$ log_file = f$element (0, ";", log_file)
$ keep = f$integer (p2)
$ if f$integer (version) .gt. 32000
$ then
$ purgex 'log_file'/keep='keep'
$ search = log_file + ";-"
$ v = 1
$vloop:
$ file = f$search ("''search'''keep'")
$ if file .eqs. ""
$ then
$ goto next_v
$ endif
$ renamex 'file' *.*;'v'
$ v = v + 1
$next_v:
$ keep = keep - 1
$ if keep .ge. 0
$ then
$ if keep .eq. 0
$ then
$ search = search - "-"
$ endif
$ goto vloop
$ endif
$end_vloop:
$ endif
$ endif
$ exit
$!++
$! Description:
$!
$! Given a file, purge it to the requested number of versions.
$!
$! If the top level version of the file is over 32000, then the
$! remaining files after the purge will be renamed so the lowest
$! version number is 1.
$!
$! P1 = File to purge (required)
$! P2 = versions to keep (optional, defaults to 1)
$!
$!
$! Author: James F. Duff
$!
$! Date: 24-Mar-2004
$!
$! Modifications:
$!
$! Who Date Version What
$!
------------------------------------------------------------------------
$! JFD 24-Mar-2004 X01-00 Original version of module
$!
$!--
Cheers,
Jim.
--
www.eight-cubed.com
In addition to all the nice suggestions here, dcl.openvms.org contains a fairly
large repository of DCL code to perform all sorts of tricks, including at least
one more version of the RENAME problem :-). Although there is no "search"
feature within the site, (that I can see) it would be well worth an evening's
effort to peruse the site, to see what additional treasure may be buried there.
$!
$ verify = F$VERIFY(0)
$ say == "WRITE SYS$OUTPUT"
$ say ""
$ say ""
$ IF p1 .eqs. "" THEN GOTO HELP
$ filename = p1
$ filename = F$PARSE( filename,,, "DEVICE" ) + -
F$PARSE( filename,,, "DIRECTORY" ) + -
F$PARSE( filename,,, "NAME" ) + -
F$PARSE( filename,,, "TYPE" )
$!
$ say ""
$ say "Operating on ''filename'"
$ on control_y then GOTO EXIT_PROC
$ on error then GOTO EXIT_PROC
$ low_version = F$SEARCH( filename+";-0" ) !Find the
lowest vers
$ IF low_version .EQS. "" THEN GOTO EXIT_PROC !File not
found
$
$ old_version = f$PARSE( low_version,,, "VERSION" ) !Get the
version
$ old_version = f$EXTRACT( 1, 5, old_version ) !Trim leading
";"
$ new_version = 1 !Start with 1
$ LOOP:
$ low_version = F$SEARCH( "''filename';''old_version'" )
$ IF low_version .NES. ""
$ THEN RENAME/LOG 'filename';'old_version'
'filename';'new_version'
$ new_version = new_version + 1
$ ENDIF
$ hi_version = - !Establish hi
version
F$extract( 1, 5, f$PARSE( f$SEARCH( "''filename';0" ),,,
"VERSION" ))
$ IF old_version .GE. hi_version THEN GOTO EXIT_PROC
$ old_version = old_version + 1
$ goto loop
$ EXIT_PROC:
$ say "End Date/Time : ''F$TIME()'"
$ verify = F$VERIFY( verify )
$ EXIT
$ HELP:
$ say ""
$ say "This procedure renames a series of version(s) of a file."
$ say "It renames the lowest version to ;1, next to ;2, etc."
$ say ""
$ say "p1 = disk:[directory]filename (version number not
necessary)"
$ verify = F$VERIFY( verify )
$ EXIT
I assume by "strictly monotonically increasing" you instead mean no
gaps in the version numbers. So that you would have, e.g., ;1, ;2, ;
3, ... instead of ;1, ;4, ;9, ....
Here is on other quick perl 'one liner':
$ perl -e "$f=shift; foreach (reverse glob qq($f;*)){ $i++; ($n,
$v)=split /;/; last if $n ne $f; rename $_, qq($f;$i)}" file.ext
With a hardcoded file name it simplyfies to:
$ perl -e "foreach (reverse glob q(file.ext;*)){ $i++; ($n,
$v)=split /;/; rename $_, qq($n;$i)}"
The part "last if $n ne $f" makes sure a single simple file spec was
passed in such that the script does not go wild.
Note... perl would process a file.ext;* as argument into many
arguments matching all the wildcarded specs unless triple quoted, so
it seemed easier and safer to hard code adding ;8 for this specific
usage.
Cheers,
Hein.
V1 = version # of "foo.bar;" (highest version)
V2 = version # of "foo.bar;-0" (lowest version)
total = V1-V2+1 (# of versions if no gaps)
Repeat "total" times with I going from 1 to total, and J from V2 to V1:
Rename ";J" to ";I"
There was logic to deal with gaps (if something in the middle was
deleted).
Feel free to reinvent it from this.
Well, the easiest would be two steps:
$ rename file.dat;* *.tad
$ rename file.tad;* *.dat
Obviously, that makes many brash assumptions.
--
David J Dachtera
dba DJE Systems
http://www.djesys.com/
Unofficial OpenVMS Marketing Home Page
http://www.djesys.com/vms/market/
Unofficial Affordable OpenVMS Home Page:
http://www.djesys.com/vms/soho/
Unofficial OpenVMS-IA32 Home Page:
http://www.djesys.com/vms/ia32/
Unofficial OpenVMS Hobbyist Support Page:
http://www.djesys.com/vms/support/
By definition, wouldn't the only requirement be one open slot, since the
procedure RENAMEs the lowest to ;1 (freeing up the prior lowest slot)?
--
Brian Tillman
Change the directory (logical) daily/weekly instead...
--
Peter "EPLAN" LANGSTOEGER
Network and OpenVMS system specialist
E-mail pe...@langstoeger.at
A-1030 VIENNA AUSTRIA I'm not a pessimist, I'm a realist