LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
Search this Thread
Old 11-26-2012, 01:03 AM   #1
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Rep: Reputation: 158Reputation: 158
Convert a string from ASCII to EBCDIC


I have some text files in EBCDIC that I want to add data to in EBCDIC.

I know I can use the dd commmand if I want to translate all the files from EBCDIC to ASCII, update it in ASCII, then convert it all back to EBCDIC. But I don't wish to do that in this case because many of the files have embedded binary data.

Right now I'm doing the following in a bash shell script to append a line in ASCII to $outfile (the output file):

Code:
echo './ ADD NAME='${1#./} >> "$outfile"
The ${1#./} is the input file name with the ./ stripped off the front of it. So if my script is passed a file name of ./XYZZY, it appends "./ ADD NAME=XYZZY" to the output file. The output file is mostly EBCDIC, so I'd like for that string to be in EBCDIC too, e.g., x'4b6140c1c4c440d5c1d4c57ee7e8e9e9e8'

Any ideas?
 
Old 11-26-2012, 03:18 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,500

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Whoa. That looks like you are building IEBUPDTE input.
Are we to presume you are doing this in zLinux as you don't seem to be concerned with little-endian <-> big-endian issues ?.
 
Old 11-26-2012, 10:19 AM   #3
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
Yes, I am building IEBUPDTE input for an MVS 3.8J system running under the Hercules emulator on my home PC. I'm concatenating the contents of thousands of individual files on my PC into one file with an IEBUPDTE ADD statement in front of each one. I'm not concerned with little-endian vs big-endian issues since the data came from a big-endian system and is going back to one. It was downloaded as a binary file, so nothing has been translated or reordered.

I've thought of a way to do this, but it is a bit of a kludge. I'll be back with an update shortly.

Edit:

This appears to be giving me the result I was after. But it involves multiple file creation for each conversion, so it seems inefficient.

Code:
echo './ ADD NAME='${1#./} > tmp1
dd bs=80 cbs=80 conv=ebcdic,block if=tmp1 of=tmp2
dd bs=80 cbs=80 conv=unblock if=tmp2 of=tmp1
cat tmp1 $1 >> "$outfile"
rm tmp1 tmp2
If I could build the ADD NAME statement in EBCDIC directly in the script without having to write it to a file and convert it twice with dd, that would be an improvement.

Last edited by Z038; 11-26-2012 at 10:58 AM.
 
Old 11-26-2012, 03:00 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,500

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Have you asked on the Yahoo Herc list ?. Used to be quite active, and all the devs are (were) subscribers.
 
1 members found this post helpful.
Old 11-26-2012, 04:09 PM   #5
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 805

Original Poster
Rep: Reputation: 158Reputation: 158
That didn't occur to me, but it's a good idea. I'll do that.
 
  


Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting IBM EBCDIC file to ASCII on Unix jjb038 Linux - General 7 11-14-2009 06:23 PM
Python: Trying to store AES encrypted string into database - can I convert to ascii? BrianK Programming 2 01-23-2009 02:58 PM
Conversion from EBCDIC to ASCII aravindts Programming 2 06-27-2007 04:05 PM
EBCDIC to ASCII in Perl ppanyam Programming 1 01-06-2006 12:35 PM
in linux & c/c++: how do I convert an ascii string to utf8 & vice versa? davidh_uk Programming 2 02-06-2005 06:55 PM


All times are GMT -5. The time now is 12:59 PM.

Main Menu
Advertisement
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