LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Conversion of big endian data from Unix to little endian data (https://www.linuxquestions.org/questions/linux-newbie-8/conversion-of-big-endian-data-from-unix-to-little-endian-data-896227/)

pandunr 08-08-2011 01:10 PM

Conversion of big endian data from Unix to little endian data
 
Currently we have migrated data from Unix linux. The data in Unix is in Big endian byte structure. Where are as Linux (suse linux) byte structure us little endian. This byte order mismatch is creating problem when data is read again in microfocus cobol.

Is there any way to set byte order in Linux is big endian?

Is there any utility to convert data in big endian byte structure to little endian byte order.

bvm2607 08-08-2011 04:10 PM

dd conv=swab if=<inputfile> of=<outputfile>

pandunr 08-12-2011 06:00 AM

dd conv=swab if=<inputfile> of=<outputfile>
 
When we use dd conv=swab if=<inputfile> of=<outputfile> it is swapping only 2 bytes. We need swapp 8 bytes at times. We used cbs=8 in option, we also tried with ibs & obs option but complete data isn't swapped.
Am I missing some option. Please help.

jefro 08-12-2011 04:00 PM

I think I read you need a much more complex way to first test the data then change it according to some features of the data. I have seen some python scrips and java scripts to do that. As I recall there are some caveats to the data based on type and size that needs to be checked.

I could be wrong too.


One site I think I read you can transfer via some network for example and the host and client should then work on the data correctly on each end to match the processor type.

syg00 08-12-2011 08:23 PM

Quote:

Originally Posted by pandunr (Post 4437019)
Currently we have migrated data from Unix linux. The data in Unix is in Big endian byte structure. Where are as Linux (suse linux) byte structure us little endian. This byte order mismatch is creating problem when data is read again in microfocus cobol.

Note that the machine architecture determines endian-ness, not the Operating System/distro. This is not really a Unix vs Linux issue strictly speaking.
Quote:

Is there any way to set byte order in Linux is big endian?
Only by running it on big-endian hardware probably
Quote:

Is there any utility to convert data in big endian byte structure to little endian byte order.
Nope, you'll have to write your own. And you'll need to know the map of the data as it was constructed. Whether it was text or binary or integer (and what size integer) or maybe even packed decimal. These fields will almost certainly all be different sizes, and will need to be handled separately.


All times are GMT -5. The time now is 03:16 AM.