1753449 Members
6216 Online
108794 Solutions
New Discussion юеВ

Re: Record Terminator

 
SOLVED
Go to solution
Ian Miller.
Honored Contributor

Re: Record Terminator

I think convert from VFC to the streamLF format that unix wants. Do this either on VMS or if no VMS system then after restoring files on to unix do convert there. You will have to write a convert program. See RMS documentation for details of record format (there is a record length word and some other stuff for VFC files. Watch out for the extra padding bytes inserted so that the two byte record length starts on a even byte offset).
____________________
Purely Personal Opinion
Hein van den Heuvel
Honored Contributor

Re: Record Terminator

Henry,

My explicit for others implied request stands: What does the file actually look like on Unix? Just give us an 'od' HEX and/or ASCII dump for the first 1000 bytes or so in a TEXT file attached to your next reply here.

If the file you are opening is a 'plain' VMS text file, then it is VARIABLE LENGTH. That means each record is preceeded by a 16 bit binary length (NOT an 4-digit number, those are only used on Magtape) and starts at an even byte offset in the file. You can read such a file on NT or Unix with a perl script like:


binmode STDIN;
while (read STDIN,$length_word,2) {
# avoid using "S" or "V". just do the math.
($length,$null) = unpack ("CC",$length_word);
$length += $null*256;
last if ($length > 32767);
$read = read STDIN,$line,$length;
print "$line\n";
read STDIN,$null,1 if ($length & 1);
}


Now if the file you are looking for is a cobol report or DCL log file it my be this VFC others alluded to. In that case it gets much more tricky to interpret it. But as a first cut you could modify my program above to skip the first 2 bytes in the record (the ones following the 2 length bytes). That way you will get the raw data, but you will loose the formatting (double-space, over-punch, new-page)

So try that perl, and output a dump if you have no success.

Good luck,
Hein.

Henry_52
Advisor

Re: Record Terminator

Thank you for your reply.
I executed "od -x" and I attached output file. Actually, I don't know about perl.
Please give me more detail information about perl command.

Thank you.

Henry

Hein van den Heuvel
Honored Contributor
Solution

Re: Record Terminator

I'd highly recommend learning Perl as a generic data processing languange.
Those shell/DCL scripts that spend 90% of their code shuffling bits of string around amidst a few serious command executions (not countingn search/grep/awk/cut as serious) are proabably better in perl (or even awk).
The converse is also true: those perl programs executing 'system' every other line should perhaps haver remained a shell/dcl script.

Anyway... judging by the data of your file you are looking at a 'fixed length record file' probably with record size 120 (dec) bytes. Indeed, on VMS, there are no terminators in such file as they serve no purpose. VMS applications, through RMS, just get the data delivered in 120 bytes chunks.

Now if you move to a lower level OS ( ;-), you'll have to do that yourself. Just like VMS comes with an indexed/keyed records access method and no Unix has that build in.

Ooops, I'm getting further of topic :-)

Back to the script. Create a file 'split.pl' with the contents:

$length = 120;
binmode STDIN;
while (read STDIN,$line,$length) {
print "$line\n";
}

Now:

perl split.pl < vms.data > unix.text

That should do it (but I did not test)

You can also do 'one-liners' like:

perl -e 'binmode STDIN; print "$_\n" while (read STDIN,$_,120)' < vms.data > unix.text


Finally... one has to wonder that the heck you are doing trying to 'vi' a file for which you are so clueless about its contents.
IMHO you should have known it was fixed length, and have a pretty good idea about the record size and the fields within the records when you start poking at this file, based on application knowledge. That stuff has nothing to do with this being Unix or VMS.

Hope my script works well enough to get you looking in the right direction!
Good luck,
Hein.



Henry_52
Advisor

Re: Record Terminator

Hi Hein van den,

Thank you for your detail information.
I executed perl script with vms file but I met Error message.
Please check below error.

Thank you.

Henry
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
syntax error in file a.pl at line 4, next 2 tokens "read STDIN"
Execution of a.pl aborted due to compilation errors.
Hein van den Heuvel
Honored Contributor

Re: Record Terminator

Well, I just did a cut from the forum and pasted the script into a unix file and it works for me (afte adjusting 120 to 12 for a simple test). If you re-typed instead of cut&paste then I'm afraid you fat-fingered it. Try again, check every character notably (, ), and ;
Try the one-liner also.
You'll figure it out. I know you will...

Hein.
Martin P.J. Zinser
Honored Contributor

Re: Record Terminator

Hello Henry,

tested Hein's suggestion on Unix. The code works fine. One thing to check, your error is on line 4, while the stuff it talks about is in Hein's example on line 3. Have you changed the program maybe? How do you execute it?

Greetings, Martin
Henry_52
Advisor

Re: Record Terminator

Hi Hein, Martin

I tried several times but It's not working.
So I changed one thing and I think It's working now !! Thank you very much Hein.:)
Please check below and let me know if this is not good.

Regards,

Henry

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# script
$length = 120;
binmode STDIN;
while ( read (STDIN,$line,$length) )
{ print "$line\n"; }

$perl split.pl < vms.data > unix.text

# command line
$perl -e 'binmode STDIN; print "$_\n" while read (STDIN,$_,120)' < vms.data > unix.text
Peter Hofman
Frequent Advisor

Re: Record Terminator

I think FTP-ing the file as type ascii from VMS to Unix should also do the trick.
Martin P.J. Zinser
Honored Contributor

Re: Record Terminator

Hi Peter,

FTP is an option if you still have your VMS system around. But if that is the case there are plenty of ways to deal with this. My reading of Henry's question was that he does not have this luxury and has to find a way to get data out of VMS backup savesets on Unix only.

Greetings, Martin