Unable to convert EBCDIC file to ASCII file

Hello all,

To give you all a little bit of background. We recently migrated from HP-UX to Redhat Linux and one of the command I used to run on HP-UX to convert an EBCDIC file to ASCII file isn't working on Linux. The code is as follow:

 
cat workout2.dat | dd cbs=250 conv=block conv=ascii > ofr1.txt

The code executes without any error on Linux, however, the output is nowhere close to what it used to produce on HP-UX.

One other interesting thing is that I used the option cbs=250 to convert 250 bytes at a time, as the record length consists of 250. But now on Linux it only produces 250 Bytes of file with this option. If I remove this option then also the output is messed up.

Note: I referred to other similar threads. But couldn't get the final answer. So please dont refer me to other link unless and until you're sure that it contains a final answer.

Greatly appreciate any response which can lead to a solution!

  • Seth

When I read your thread title, the first thing jumping to my mind was dd . This failing, did you consider recode or iconv , both of which should be available on the linux platform?

Both iconv and dd are available on Redhat and can convert from EBCDIC to ASCII.

Translating EBCDIC isn't trivial unfortunately. The Linux version of dd just does a blind character-to-character remapping which misses some of EBCDIC's finer subtleties... I can't remember the details but something to do with the order of digits in extended numbers. iconv would do a much better job.