LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Converting IBM EBCDIC file to ASCII on Unix (http://www.linuxquestions.org/questions/linux-general-1/converting-ibm-ebcdic-file-to-ascii-on-unix-768930/)

jjb038 11-13-2009 10:17 AM

Converting IBM EBCDIC file to ASCII on Unix
 
I am trying to convert an IBM mainframe file that was ftp'ed to a Unix server to an ASCII file. File on the IBM is EBCDIC, VB, LRECL=9996, BLKSIZE=10000. A binary transfer is used to ftp the file to Unix. Have tried using the Unix dd statement to do the conversion but the output file is not coming out split correctly. I am not sure if the problem is with the blocking on the Unix server after the ftp. Is there a way of telling what the block size is of the Unix file? Anyone have any ideas on what to try. All input would be greatly appreciated.

choogendyk 11-13-2009 06:22 PM

Is it coming out garbage? Or is is some pattern you can recognize? If you had packed decimals, it could come out garbage. You would need to convert that on the IBM side before bringing it over.

Is what you tried something like this: http://docstore.mik.ua/orelly/unix2.1/upt/ch35_12.htm ?

i92guboj 11-13-2009 07:01 PM

I might be missing something, but I don't know what 'dd' does in the middle of the picture. dd copies raw bytes from one place to another, it doesn't understand encoding systems or whatever.

If you used ftp in binary mode, you should have exactly the same file on both places. You can always use some checksum tool or something to make sure that the original file and the one in the unix machine is the same. If they don't match, then the problem is in the transfer, so you will need to sort that out first.

Assuming it is, you just need a tool to convert ebcdic to ascii. I know there are tools to do this, and there are also perl modules for the same purpose. I haven't experience with them though so I can't give any concrete advice.

syg00 11-13-2009 08:21 PM

You *really* don't want to be directly ftp'ing VB files like that. It won't work. Period.
Best might be to ocopy to a [zh]fs on USS on the mainframe first.

choogendyk 11-13-2009 08:46 PM

Quote:

Originally Posted by i92guboj (Post 3756394)
I might be missing something, but I don't know what 'dd' does in the middle of the picture. dd copies raw bytes from one place to another, it doesn't understand encoding systems or whatever.

yup. you're missing something. :cool:

If you do a man on dd, you'll see "dd - convert and copy a file." It will convert ascii to ebcdic and vice versa. It will pad new line terminated records to fixed length records. It will change case. It will swap the order of byte pairs. And you can provide custom conversion tables. One of the longer running threads (with 556 posts over the last 4 years) here on linuxquestions is Learn the dd command.

i92guboj 11-13-2009 08:52 PM

You always learn something everyday :)

Sorry for tainting the thread.

choogendyk 11-14-2009 09:02 AM

I found this extremely interesting tech support article that describes what happens when you use ftp to transport a file from a mainframe to a unix system or PC -- http://support.sas.com/techsup/technote/ts642.html. Scroll down to "Moving data between platforms." Following that are some fairly detailed descriptions of possible solutions. Cool stuff.

syg00 11-14-2009 05:23 PM

The benefit of using ocopy is that it uses the mainframe environment (and known code pages) to create a Unix file in ASCII prior to ftp. Removes a lot of potential problem points. IEBGENER will create an EBCDIC (non *nix) file that still needs converting (by default).


All times are GMT -5. The time now is 07:14 AM.