Binary File Compatibility Between ULTRIX and Other UNIX Systems

Adrian J Ho adrianho at barkley.berkeley.edu
Sat Apr 6 12:06:57 AEST 1991


In article <26467 at adm.brl.mil> siggins at kodak.com (Richard Siggins, B-150B, Eastman Chemical Company Research, X- 3762) writes:

>As a new UNIX systems person I was dismayed to discover that floating point and
>integer numbers are not stored in the same format in a binary file on ULTRIX vs
>most other UNIX systems.  It seems that the bytes are in the reverse order or
>some similar condition.

It's actually a problem with the architecture used (VAX, MIPS) --
nothing to do with Ultrix.

>			Does anyone know of a file transfer method that will
>correctly translate the data?   In particular I am interested in data from an
>IBM RS6000 and a DECsystem 5000.

There is no general file transfer method that handles arbitrary-endian
data.  Your best bet is to *convert* the files before transferring
them.  To do that, you have to know the exact format of the data
files.

Once you know that, all you have to do is write a program that reads
in each data item (depending on the size), reverses the bytes (*not*
the bits), and writes it back out again.

One more thing: If you have the sources to the programs you run, and
anticipate the need to transfer data amongst several different
architectures, consider writing out your data in ASCII format.  IMHO,
it's the only truly portable data format, and you'd only have problems
if (a) you have limited disk space [get some more], (b) the data
values generated are too large for the destination architecture (eg.
trying to store 2^48 in a 32-bit integer) [scale your data if
possible], or (c) you use EBCDIC ["dd" to the rescue 8-)].

Good luck!



More information about the Comp.unix.questions mailing list