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

How can I read locked files?

SOLVED
Go to solution
Sami Zeitoun
Occasional Visitor

How can I read locked files?

Hi all,
I am trying to read a text file that is locked by another application. Is there any special API or flag that I can use in order to be able to read this file?? something that can ignore the locking mechanism??
I tied to use SYS$OPEN but It does not work!!
Can you help me?

Thanks,
Sami.
9 REPLIES
Dale A. Marcy
Trusted Contributor

Re: How can I read locked files?

One trick is to do a backup/ignore=interlock to a temporary file and then type out the temporary file.
Uwe Zessin
Honored Contributor

Re: How can I read locked files?

But please note that that only works if the data has been flushed to disk and the file header been updated. You won't have any success if you see file sizes like 0/5 (0 used, 5 allocated).
.
Jan van den Ende
Honored Contributor

Re: How can I read locked files?

... but be aware that any data not yet physically written to disk will NOT be included.
Specifically, indexed files can have the key(s) info in other parts of the file as the data, and there is a serious chance of having data and key(s) out of sync. (one before, the other after the write-to-disk.

Then again, if this only is for a glimp of the progress, it is a perfectly good method.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Hein van den Heuvel
Honored Contributor
Solution

Re: How can I read locked files?

Try SYS$OPEN with FAC=GET, SHR=UPD.
That is: indicate read access only, allowing writers.
If the application tolerates reader, but no writers, then that is the appropriate open.

Try CONVERT/SHARE

If that still does not work, then as Dale says, try BACKU/IGNORE=INTERLOCK.
This uses QIO ACCESS to open the file with FIB$V_NOLOCK. (IO Users Ref manaual. ACP-QIO Table 1-3 FIB Fields)

However, since the application apparently was not interested in sharing, significant chunks of the data (all!) might not have been flushed out to disk, and most likely the EOF pointer has not been updated.
The default RMS buffer size (assuming the application is using RMS!) has been bumped from 16 blocks to 32 blocks. So unless teh application actually asked for action (SYS$FLUSH), the last 16KB of data will likely only exists in process private memory (ANAl/SYSTEM... SHOW PROC/RMS=(RAB,BDBSUM) to confirm).

hth,
Hein.
Sami Zeitoun
Occasional Visitor

Re: How can I read locked files?

Just a little clarification... I typed SYS$OPEN by mestake... I am trying to access a file using fopen.
Hein van den Heuvel
Honored Contributor

Re: How can I read locked files?

Doesn't matter. The same principle applies to the C RTL open.

You made a more mEstakes in that line...

>>> I tied to use SYS$OPEN but It does not work!!

tie-ing open probably restricts its effectivness

and, let me assure you that SYS$OPEN works.
If It did not, then all hell would break loose, wouldn't it?
Not It might not have done what you wanted, but it did faithfully do what you asked.

Just kidding,

Hein.

Wim Van den Wyngaert
Honored Contributor

Re: How can I read locked files?

If the program that locks the file didn't post the eof yet, it may be necessary to do set file/end on the copy made with backup/ign=int. This may result in more content or garbage begind the content or both.

Wim
Wim
Sami Zeitoun
Occasional Visitor

Re: How can I read locked files?

Thanks all,
Using BACKUP/IGNORE=INTERLOCK is not an option for me (performance issues). I'll try to use FAC=GET, SHR=UPD hoping it will help, but if I understand correctly, if the application locking the file does not tolerate readers then there is no way to read the file and "ignore" the locking right??!!

Sami.
Hein van den Heuvel
Honored Contributor

Re: How can I read locked files?

The default (log) file write behaviour, is not to share, and not to flush. This provides the best speed, but the least function. DCL flushes based on a timer, but that is in its code. If the application code is under your control, then you coudl do something similar. If the applicaiton code can not be changed, and you accepted the default, then case is hopeless for mere mortals.

Wizards could possibly use privved code to queue an AST to the user process telling it to flush if they can figure out the rab (make one up with a generate RAB$W_ISI).


It is hard to imagine why backup/ignore would pose a performance issaue. We are not talking about going to tape or a saveset. Just using backup as an alternative to copy. IF backup/ignore=interlock works for you, but you have reasons to reject it, then you can write a modest tool to use QIO to open the file with FIB$V_NOLOCK as I mentioned. The VMS freeware probably has examples to get you going (there are QIO access examples in my RMS_TOOLS freeware contribution).

Good luck!
Hein.