How to read variable length file on UNIX generated by Mainframe?

Hi All,
We have variable block file generated on Mainframe. We have to process the file on unix. So we FTPed the file on binary (as it has packed decimal fields). but i don't know how to read the file on unix.

As you know variable block file will have a data like
record length followed by data and next set of record length followed by data. As this is a binary file there won't be any new line.

Is there a way to read the file and write it to a fixed length format.

Thanks in Advance.

Regarding the pack decimal fields, unless you have other software like MicroFocus COBOL Workbench or SAS which can read and process binary/packed decimal data (I have done such on Windows, not Unix however), an easy solution would be to convert the packed decimal fields into display fields on mainframe then you can download the file as ascii. This would also solve you problem regarding reading in the variable block records all in one line.

Undoubtedly it can be done (Perl, for example, is often used for this type of application), but you would have to provide a detailed description of both file formats, the current and the desired.

For example, you mention that each record is preceded by its length but neglect to specify how the length is encoded. With regard to the output format, how should the fixed width be determined? Should it be equal to the longest record? Should it be some other value? If that value is insufficient to accommodate a record, should that record be truncated? How should records be padded? Should the output be newline terminated? Should the records be modified in any way, such as unpacking binary values?

Again, if you would like assistance, you will have to do a much more thorough job of describing the file formats and the conversion process.

If the file formats you're working with utilize some mainframe standard, a link that explains them would be invaluable for those who are not familiar with them but could otherwise assist.

Regards,
Alister