Operating System - HP-UX
1826428 Members
3391 Online
109692 Solutions
New Discussion

Re: migrated binary data files

 
Courtney Brown_1
Occasional Advisor

migrated binary data files

We migrated binary data files from a sequent dynix system. Our utilities (written in c) for reading/writing were re-compiled in hp-ux. Problem is we cannot read the files because it appears the storage format of the various numeric data types in the binary files differs between the two environments. Hence we cannot correctly read the binary data files. Are there existing utilities to help us with this problem?

od on a single integer (1) looks like this on dynix:
00000000000 000001 000000
00000000004
after migration to hp-ux, it looks like this:
0000000 000400 000000
0000004

5 REPLIES 5
f. halili
Trusted Contributor

Re: migrated binary data files

Have you tried ftp to migrate the files.
FTP has an option "binary" to set the file transfer type to binary.

Example:
# ftp 162.69.77.66
Connected to 162.69.77.66.
220 FTP server (GNU inetutils 1.3.2) ready.
Name (162.69.77.66:root): fnhalili
331 Password required for fnhalili.
Password:
230 User fnhalili logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bi
200 Type set to I.
ftp>
derekh
Courtney Brown_1
Occasional Advisor

Re: migrated binary data files

ftp in binary mode is what I used to produce the results in my example.
Kofi ARTHIABAH
Honored Contributor

Re: migrated binary data files

Courtney:

The reason is that the sequent is a "little endian" architecture and HP is "big endian" architecture. check out:
http://cache.intersys.com/downloads/documentation/cache31/docs/misc/cvendian.html

do a search on the net for "endian conversion" there are utilities out there for performing the conversion.

Good luck
nothing wrong with me that a few lines of code cannot fix!
Gregory Fruth
Esteemed Contributor

Re: migrated binary data files

Using binary files from one platform on different platform is
always tricky. You need to take into account the machine's
word size (32-bit, 64-bit, etc.), byte ordering (big-endian,
little-endian, etc.), struct padding (if using structs), type size
(int=32bits, short=16bits, etc.), one's/two's complement
(in the old days, anyway), type alignment rules, etc.

I've translated your octal od output to binary:

Dynix:
octal: 00000000000 000001 000000
binary: 00000000000 0000 0000 0000 0001

HP-UX:
octal: 0000000 000400 000000
binary: 0000000 0000 0001 0000 0000

It seems like the bytes have been swapped. If you're lucky,
you might be able to just use "dd conv=swab" on the file to
swap bytes, or the swab() function (or something else
of your own devising) in your C program.
Victor BERRIDGE
Honored Contributor

Re: migrated binary data files

Hi,
I agree with Kofi, there are also archive utilities you can use such as PAX to generate portable archives...

Good luck

Victor