- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to convert ebcdic data?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 12:47 PM
тАО07-22-2003 12:47 PM
I have some legacy data that comes in from an IBM mainframe. All the string data is in ebcdic format and I need to convert it to ascii. My problem is that when I use dd to convert the data all the strings are ok but the binary data is garbage. If I don't use dd, the binary data is perfect but the strings are garbage. Is there anyway to make dd convert only the strings and leave the binary parts of each record alone.
TIA,
Bob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 12:50 PM
тАО07-22-2003 12:50 PM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 12:55 PM
тАО07-22-2003 12:55 PM
Re: How to convert ebcdic data?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 12:57 PM
тАО07-22-2003 12:57 PM
Re: How to convert ebcdic data?
My company purchased a FilePort for Unix product from SyncSort specifically for this purpose. The product is good and easy to use.
http://www.syncsort.com/products.htm
Elena.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 01:20 PM
тАО07-22-2003 01:20 PM
Re: How to convert ebcdic data?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 01:41 PM
тАО07-22-2003 01:41 PM
Re: How to convert ebcdic data?
I have several files to convert. The simplest one has just a few fields:
Offset Length Description
0 4 Binary integer
4 20 ebcdic string
24 2 Binary integer
26 20 ebcdic string
46 60 ebcdic string
106 48 array of 4 12-byte BCD integers
------
154 bytes total
Can you show me a perl example and then I should be able to handle the other files. Please, please??
TIA,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2003 02:07 PM
тАО07-22-2003 02:07 PM
Re: How to convert ebcdic data?
This looks like duck soup. Here's my untested (even for syntax) example based on your layout:
--------------------------------------
#!/usr/bin/perl -w
use strict;
use Convert::EBCDIC;
use constant TYPEDEF => 'a4 a20 a2 a20 a60 a48';
# declare each field as binary data, 'a' format follwed by length
# note that we can treat the 4 12-byte BCD's as one field because we
# are not converting them
my $recsz = length(pack(TYPEDEF,()));
my $b;
my $n = read(STDIN,$b,$recsz);
while ($n == $recsz)
{
# unpack fields specified using TYPEDEF in array
my @a = unpack(TYPEDEF,$b);
# convert each EBCDIC string to ASCII $a[0] = 1st field, $a[1] = 2nd, ...
my $s1 = Convert::EBCDIC::ebcdic2ascii($a[1]);
my $s2 = Convert::EBCDIC::ebcdic2ascii($a[3]);
my $s3 = Convert::EBCDIC::ebcdic2ascii($a[4]);
# pack data using unchanged fields from array for binary and
# converted EBCDIC strings where appropriate
my $out = pack(TYPEDEF,$a[0],$s1,$a[2],$s2,$s3,$a[5]);
print $out;
$n = read(STDIN,$b,$recsz);
}
-------------------------------------------
Note that this script functions as a filter, so
convert.pl < oldfile > newfile
Again, you will need to download and install the Convert::EBCDIC module. Installing is easy. After downloading, gunzip it, untar it, and view the README file. It will guide you through the rest of the module install. Again, check this very carefully because I typed in 'on the fly' -- and I ain't exactly known for my good typing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2003 05:35 AM
тАО07-23-2003 05:35 AM
Re: How to convert ebcdic data?
We used FilePort to migrate from mainframe to UNIX, a lot of data. So, if you need to convert just several files, you do not want to purchase this software, but you probably can get a demo/trial version for free.
Elena.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2003 06:14 AM
тАО07-23-2003 06:14 AM
Re: How to convert ebcdic data?
The perl script actually worked. I just cut and pasted it and ran it. We have been thinking that it would make it easier to process on the HP end if we added a linefeed character to each record. Can we just add a '\n' to the print command? Also, is there some documentation on the pack and unpack procedures?
Thanks,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2003 06:16 AM
тАО07-23-2003 06:16 AM
Re: How to convert ebcdic data?
[please no points]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2003 06:23 AM
тАО07-23-2003 06:23 AM
Re: How to convert ebcdic data?
I'm glad my advanced one-finger hunt-and-peck typing actually worked. To add a LF, all you need to do is change print $out; to print $out,"\n"; However, THIS IS DUMB. You still need to process it as fixed length records because in your binary data you could easily have a 0x0a (LF) byte that would be perfectly valid data but not be the end of the record.
To get more documentatio, do a man perlfunc. All the standard Perl functions are lumped into this one man page so it's not possible to get jusy the pack and unpack functions. It's a rather big man page so I would print it. viz man perlfunc | lp.