Operating System - OpenVMS
1827838 Members
1451 Online
109969 Solutions
New Discussion

How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

 
Manajit Halder
New Member

How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

Hi,

PROBLEM DESCRIPTION:
I have a stream_LF file of single line without LF character at the end of line. When I dump it using DUMP command it doesnot show any LF or CR character.
It gives an error when ana/rms command is given. It says "*** VBN 1: Last stream record does not contain a delimiter."

Now I want to add a LF character to the end of the line, because the application which uses this file reads the file by checking LF character, since LF character is not there, after reading the file it shows zero size i.e. file is empty.
I have added the LF character i.e. '\n' at the end of line manually, it works now, file size is not zero, contents are also same,
but the file property is getting changed from Stream_LF to Variable.

REQUIREMENT:
I want to know is there any way to add a LF character at the end of line in Stream_LF file other than adding it manually, so that it behaves like Stream_LF sequential file with all the RMS FILE ATTRIBUTES are correct and the LF character is only visible with octal dump.
6 REPLIES 6
Robert Gezelter
Honored Contributor

Re: How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

Manajit,

The CONVERT utility can convert a variable length record file to a STREAM_LF file.

You will need an FDL file specifying, among other things:

FILE organization sequential
RECORD FORMAT stream_lf

I urge a review of the documentation on the CONVERT utility, it is extremely useful in situations such as these.

The entire documentation set is available online on the OpenVMS www site at http://www.hp.com/go/openvms

- Bob Gezelter, http://www.rlgsc.com
Steven Schweda
Honored Contributor

Re: How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

What does "added [...] manually" mean?
"EDIT /TPU" does _not_ change the record
format for me.

For adding a NL at end-of file, COPY seems
to work for me:

alp $ dump /byte EOL_NO.TXT
[...]
00 00 00 00 00 00 00 00 00 00 00 65 64 63 62 61 abcde........... 000000
[...]

alp $ dump /byte EOL_ONLY.TXT
[...]
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A ................ 000000
[...]

alp $ copy EOL_NO.TXT, EOL_ONLY.TXT EOL_YES.TXT

alp $ dump /byte EOL_YES.TXT
[...]
00 00 00 00 00 00 00 00 00 00 0A 65 64 63 62 61 abcde........... 000000
[...]

All the files are "Record format: Stream_LF".

That's on VMS Alpha V7.3-2, but it probably
works practically anywhere.
Hein van den Heuvel
Honored Contributor

Re: How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

>> PROBLEM DESCRIPTION:
I have a stream_LF file of single line without LF character at the end of line.

Well, then you do NOT have a stream_lf file. Because those have a terminator at every record. You just have a file which claims to be stram_lf, and looks a lot like it and you are hoping VMS/RMS is willing to deal with it.

>> the application which uses this file reads the file by checking LF character,

OpenVMS/RMS itself will return that last record, even if it does not have a terminator. So it sounds like it is really an application problem in that the provider and the consumer are not in sync, and neither is using the OpenVMS record IO.

Fear not, RMS can help... as long as that last record is not too long (no more than 32K or maybe even 64K).

As Bob already replied, just CONVERT the file. If the file is already marked stream_lf, then you do NOT need to provide an FDL.
Just do $CONVERT/STAT


btw... there is some stuff not exactly right in this space in OpenVMS.

Witness:

$ create/fdl=sys$input streamlf.tmp
record; format stream_lf
$ appen sys$input streamlf.tmp
this is line 1
this is line 2
this line will be broken
$ type streamlf.tmp
this is line 1
this is line 2
this line will be broken
$ set file/attr=ffb=45 streamlf.tmp
$ type streamlf.tmp
this is line 1
this is line 2
this line will
$ anal/rms/fdl streamlf.tmp ! No error. Bad
$ back streamlf.tmp streamlf_backup.tmp
$ anal/rms/fdl streamlf.tmp ! No error. Bad
$ copy streamlf.tmp streamlf.tmp_copy.tmp
$ anal/rms streamlf_copy.tmp
*** VBN 1: Last stream record does not contain a delimiter.
Unrecoverable error encountered in structure of file.
$ conv/stat streamlf_copy.tmp streamlf_convert.tmp
$ anal/rms/fdl streamlf.tmp ! No error. Good

Problems:

[DUMP/BLOC=COUNT=1 to verify]

1) anal/rms apparently sees the invalid terminator beyond the end-of-file byte. A buffer overrun error of sorts.

2) backup copies data beyond that eof-byte, but it refuses to copy beyond the eof-block.
Inconsistent. Either honor both or neither.
Btw.. I'd really like to have a BACK/IGNORE=EOF for those locked output files

Cheers,
Hein.
Hoff
Honored Contributor

Re: How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

You want to have Captain Kirk use the Starship Enterprise transporters to Beam the Linefeed character directly into the file? :-)

But seriously, what created the file?

It's busted.

You're going to have to open the file and add it yourself (either in the software that generated the file, or in a local conversion tool) or you're going to have to recode the receiver to be more tolerant of data corruptions in the input file.

The reason you're seeing the conversion to variable format is because the output file was not opened as a stream LF file.

Eons ago, this particular file structure error used to cause RMS itself to crash with an exec-mode bugcheck. But I digress.

Stephen Hoffman
HoffmanLabs LLC
Hein van den Heuvel
Honored Contributor

Re: How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

Actually.... just for grins... here is a command file to fix the file.


---- add_last_terminator.com ------
$if p1.eqs."" then exit
$eof = f$file(p1,"eof")
$ffb = f$file(p1,"ffb")
$rfm = f$file(p1,"rfm")
$lrl = f$file(p1,"lrl")
$mrs = f$file(p1,"mrs")
$set file/attr=(mrs=512,lrl=512,rfm=fix) 'p1
$open/read/write file 'p1
$key = "1234"
$key[0,32]=eof
$read/key=&key file record
$!show symb record
$!show symb ffb
$!show symb eof
$record[ffb*8,8]=10
$write/update/symbol file record
$close file
$ffb=ffb+1
$set file/attr=(mrs='mrs',lrl='mrs',rfm='rfm',ffb='ffb',ebk='eof') 'p1


Cheers,
Hein.
Hein van den Heuvel
Honored Contributor

Re: How to regain aStream_LF file with all the RMS FILE ATTRIBUTES correct.

And yes, before I get clever replies, the 1-in-512 case of ffb being pushed into the next block is left an an excercise for the silly.
Just converting the file is so much easier :-).

Hein.