HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

How program can find out that a file can be copied?

 
SOLVED
Go to solution
Jurek Sokolowski
Occasional Contributor

How program can find out that a file can be copied?

I need to copy a file with LIB$SPAUN('copy… . What system service can I use to determine that file to be copied is not allocated by other program (e.g. that file transfer from different machine has finished). From DCL I can use SHOW DEV /FIL to check it, but I have no idea how to do that from FORTRAN or C level.
6 REPLIES
Volker Halle
Honored Contributor

Re: How program can find out that a file can be copied?

Jurek,

there is no system service to tell, whether a file is opened from another process.

You could try to open the file in exclusive mode, allowing no sharing, which would fail, if another process has the file open.

Volker.
Kris Clippeleyr
Honored Contributor

Re: How program can find out that a file can be copied?

Jurek,

You might want to try SYS$OPEN.
See HELP SYSTEM_SERVICES $OPEN , and the Record Management Services Reference manual.

Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Karl Rohwedder
Honored Contributor

Re: How program can find out that a file can be copied?

Have a look into the utility FILES_INFO.
It can display, if a file is locked and by whom.
Source code (C and macro) is provided.
May you can get some hints.

You find it at the usual place at Hunter Goatley filearchive:

http://www.process.com/openvms/index.html

regards Kalle
Volker Halle
Honored Contributor
Solution

Re: How program can find out that a file can be copied?

Jurek,

the following statement in FORTRAN could do, what you want:

OPEN (UNIT=1, FILE='test.dat',STATUS='OLD')

$! File test.dat not access by any process
$ run ITRC_965548

$! Access file
$ open/read x test.dat
$ run ITRC_965548
%FOR-F-OPEFAI, open failure
unit 1 file USERDISK1:TEST.DAT;
user PC 00000000
-RMS-E-FLK, file currently locked by another user
...

Volker.
Jurek Sokolowski
Occasional Contributor

Re: How program can find out that a file can be copied?

Opening a file as a test is simple and works fine. Thank you very much for your help.
Jurek
John Gillings
Honored Contributor

Re: How program can find out that a file can be copied?

The best approach is to simply attempt to copy the file and react to any errors. Any test is subject to timing windows. Yes, the file may be available NOW, but that doesn't say it will still be available when you attempt the copy.

The simplest way to copy a file under program control is using callable CONVERT.

Attached is a MACRO32 program to perform a COPY. Check the return status to see if it was successful.

A crucible of informative mistakes