Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in OPENVMS?

Randy Armstrong
Occasional Visitor

Bug in OPENVMS?

I am using the following dcl to look at the file attributes of a file and if the file is zero blocks and zero allocated, to rename the file to .bad

Occasionally, even though such a file is found, it does not rename it and no error messages appear. If I run the command over, then it works.


$ sts1 = f$file_attributes("dwh$stats:ssub130c1.dat;-''countc1'","alq")
$ sts2 = f$file_attributes("dwh$stats:ssub130c1.dat;-''countc1'","eof")
$ if sts2 .eq. "0" .and. sts1 .eq. "0" then rename/log dwh$stats:ssub130c1.dat; .bad

Any suggestions?
10 REPLIES
Robert_Boyd
Respected Contributor

Re: Bug in OPENVMS?

I have one suggestion -- remove the quotation marks from the zeros in the if statement.

See if that makes any difference.

Cheers,

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
Ian Miller.
Honored Contributor

Re: Bug in OPENVMS?

Could there be something else accessing the file or directory at the time of the rename?
How do you know that the file is found but the rename fails?

If you did
$ if sts2 .eq. "0" .and. sts1 .eq. "0"
$ then
$ write sys$outout "renaming file"
$ rename/log dwh$stats:ssub130c1.dat;
$ endif

then you would know the if statement was true and the rename attempted.
____________________
Purely Personal Opinion
Antoniov.
Honored Contributor

Re: Bug in OPENVMS?

For me, some other application keep file locked so rename fails.
However .eq. operator works only with number and you could remove quotes from zero.
Again, after rename, store status: you can understand why rename doesn't work.

Antonio Vigliotti
Antonio Maria Vigliotti
Mobeen_1
Esteemed Contributor

Re: Bug in OPENVMS?

Randy,
Can we look at

$ sh sym sts1
$ sh sym sts2

thanks
Mobeen
Jan van den Ende
Honored Contributor

Re: Bug in OPENVMS?

Randy,

Welcome to the VMS forum!


two things:

You are trying to rename another file than the one you are checking!

(unless there is only one version, and "countc1" equals 0 (zero).


if you are trying to run this sequence in an environment where versions of this file are regularly created

then you _MAY_ even be checking "alq" & "EOF" for different files!

I would suggest to first "lock on to" a specific file by using f$search into a symbol, say "fil"

Now, execute both checks, and the conditional rename, on "fil"

.. and if you want some debug to go with it,
make the if .. rename into an if .. then .. else
and catch $status.

(I frequently define a symbol DEBUG, with default value "!" and start a debug (display?) line with it.
Depending on a start param, in debug mode you let DEBUG be a space.)

Hope this helps.

Proost.

Have one on me.

Jan

Don't rust yours pelled jacker to fine doll missed aches.
Randy Armstrong
Occasional Visitor

Re: Bug in OPENVMS?

I will take out the quotes and see what difference it makes.

I know the rename fails as this procedure runs in batch, produces a log and scans over 200 files. I can see where it looked at the zero block file but did not rename it. If the file was locked, an error message would have appeared.
Robert_Boyd
Respected Contributor

Re: Bug in OPENVMS?

following up on Jan's suggestion here's what the code would look like to be more secure on working on just 1 version of the file:

$ test_file = f$search("dwh$stats:ssub130c1.dat;-''countc1'")
$ sts1 = f$file_attributes(test_file,"alq")
$ sts2 = f$file_attributes(test_file,"eof")
$ if sts2 .eq. 0 .and. sts1 .eq. 0 then -
$ rename/log 'test_file' .bad
Master you were right about 1 thing -- the negotiations were SHORT!
Hein van den Heuvel
Honored Contributor

Re: Bug in OPENVMS?


I agree with Jan: The most likely reason for failure is that you are testng two different files.

Let's say you start with file ;2, ;3, ;4 and countc1 = "1"
So on the ALQ test you test file ;3
Now imagine file ;5 is created after the ALQ test and the EOF test.
In that case the EOF test will act upon ;4 !

Solution:
1) - just test ALQ, the EOF adds no value

2) Establish the file name firmly:

$file = f$search("dwh$stats:ssub130c1.dat;-''countc1'")
$if file.ne.""
$then
$if f$file(file,"alq") + f$file(file,"eof") .eq. 0 then rename/log 'file .bad
:

Hein.


Wim Van den Wyngaert
Honored Contributor

Re: Bug in OPENVMS?

Garry Fruth
Trusted Contributor

Re: Bug in OPENVMS?

If I interpret the code fragment correctly, the rename command does not necessarily rename the zero block file. If COUNTC1 = 1, and there is a ;3 and a ;2 version of the file. The f$file lexicals would check on ;2 (i.e. "dwh$stats:ssub130c1.dat;-''countc1'" = "dwh$stats:ssub130c1.dat;-1"), but the rename command would affect ;3. I concur with Jan's suggestion.