LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 11-13-2009, 10:17 AM   #1
jjb038
LQ Newbie
 
Registered: Nov 2009
Posts: 1

Rep: Reputation: 0
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.
 
Old 11-13-2009, 06:22 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
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 ?
 
Old 11-13-2009, 07:01 PM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,029

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
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.
 
Old 11-13-2009, 08:21 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,808

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
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.
 
Old 11-13-2009, 08:46 PM   #5
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Quote:
Originally Posted by i92guboj View Post
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.

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.
 
Old 11-13-2009, 08:52 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,029

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
You always learn something everyday

Sorry for tainting the thread.
 
Old 11-14-2009, 09:02 AM   #7
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
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.
 
Old 11-14-2009, 05:23 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,808

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
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).
 
  


Reply

Tags
dd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SED - Converting UNIX to DOS file aurelio26 Linux - Newbie 7 04-09-2008 12:15 AM
Converting float to ascii in C C_to_be Programming 2 10-29-2007 06:41 PM
Conversion from EBCDIC to ASCII aravindts Programming 2 06-27-2007 03:05 PM
EBCDIC to ASCII in Perl ppanyam Programming 1 01-06-2006 11:35 AM
Converting ASCII to Binary? Darx Linux - Software 0 04-08-2004 10:43 AM


All times are GMT -5. The time now is 12:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration