Online Expert Day - HPE Data Storage - Live Now
April 24/25 - Online Expert Day - HPE Data Storage - Live Now
Read more
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find whether the content of a file is blank ?

SOLVED
Go to solution
Davor_7
Regular Advisor

How to find whether the content of a file is blank ?

in a script, it will create many log files and i want to check whether some log files are blank.

which sentence(lexical) to use?

$
$if (****what to input here****?)
$...
8 REPLIES
Heinz W Genhart
Honored Contributor

Re: How to find whether the content of a file is blank ?

$ IF f$file_atributtes("file.type","alq") .EQ. 0 THEN file_is_empty

Hope that helps
David B Sneddon
Honored Contributor

Re: How to find whether the content of a file is blank ?

Would using the EOF attribute not be better?
A file may have been preallocated but not yet
used.

$ IF f$file_atributes("file.type","EOF") .EQ. 0 THEN file_is_empty

An ALQ value of zero is indeed and empty file.

Dave
Wim Van den Wyngaert
Honored Contributor

Re: How to find whether the content of a file is blank ?

I would replace alq by eof.
This to avoid that 0/4 (dir/siz=all) is considered not empty.

Wim
Wim
Heinz W Genhart
Honored Contributor
Solution

Re: How to find whether the content of a file is blank ?

If the file is stil open (dir /size=all displays 0/4) the lexical F$File_atributtes will not be able to get required information because the file is locked >>>> %SYSTEM-W-ACCONFLICT, file access conflict
So F$File_atributtes may be used with argument eof or alq and You have to do some errorhandlink in case the file is locked
Davor_7
Regular Advisor

Re: How to find whether the content of a file is blank ?

oh thanks all!
good explanations
Wim Van den Wyngaert
Honored Contributor

Re: How to find whether the content of a file is blank ?

If the file can be open, use a dir/siz=all/out=tmp and parse tmp for the file size.

Wim
Wim
Jan van den Ende
Honored Contributor

Re: How to find whether the content of a file is blank ?

Wim,

I really can not support that, for 2 reasons:

1. a file that was opened for write for the first time, and is not yet closed, will ALWAYS return 0/ whether it has been written to or not, because the EOF will only be updated by the CLOSE

2. a LOG file open for write will have been deferred written to, meaning that the data that belongs to the file still is in buffer memory, and has not yet been transferred to the file on disk.
Meaning the LOG has been written to, but the disk FILE would still show as 0/...

Those files WILL however turm up as LOCKED, so handling the LOCKED error as "not yet known - still active" will give better info.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Wim Van den Wyngaert
Honored Contributor

Re: How to find whether the content of a file is blank ?

Jan,

It was just a solution to bypass the lock message.

1. Not always but often.
2. Agree but he should test if the file is locked if he needs that.

Wim
Wim