Reading hex data from assembler

Hi,

I have files that has got ebcdic character set and also, there are fields like binary and hex fields. is there a way to convert this to normal ascii data by taking care of comp & comp-3 fields?

Many Thanks!!

Have you tried dd with conv=ascii ?

This method will not work if the file has comp and comp-3 fields.

There is a Perl Module that should be able to do it for you.

Convert::IBM390 - search.cpan.org

yes, I have tried dd command and it doesnt work and I am not at all aware of perl. can I do that using ksh?

Write a cobol program. http://opencobol.org

sorry - I was looking for a KSH solution.

Do you know the starting position and length of each binary and packed decimal field.

yes I am aware of the meta data of the file.

Do you think it is possible to use cut and dd to copy the easy parts, and then write a script to translate the binary/packed decimal, then put it back together.

Something like:

echo `cut -c1-100` >>output
echo `cut -c101-110 >>packeddecimal
echo `cut -c 111- ` >>output2

then
while read pd
do
convert pd >>packdecimal2
done <packeddecimal

Then
Paste the files back together.

1) Do you have the code of the program which wrote the file?
2) Was the file created on your current server? If not, what server was it?
(This is a dig for byte-reversal).
3) Is it the file fixed-length records?
4) Is it a file with line-feed as the record terminator?
5) How long is each record?
6) How many records?
7) What is the record layout? What is the picture of each field?
8) Can you post a sample of a few records in hexadecimal (blotting anything confidential with FF or 00), showing how you would expect the conversion to take place.
9) You you have any high-level languages on your server?
10) Any chance of getting the file written in a more suitable format for a unix server?
11) jgt has the best suggestion so far (use Cobol).

From previous posts,

pd=`cut -c101-104`       #4 byte packed decimal field
                                   # Cobol PIC S9(7) COMP-3 
echo (-e) "$pd\c" |hd |pd2disp   # (-e) optional SUSE yes, SCO no  

where pd2disp

read discard a b c d e f
digit=`echo $d|cut -c1`
sign=`echo $d|cut -c2`
if [ $sign = f ]
then
  echo "$a$b$c$digit+\c"                  
# Cobol PIC S9(7) SIGN IS TRAILING SEPARATE CHARACTER
else
  echo "$a$b$c$digit-\c"
fi

hd (hexadecimal dump) is the equivalent of debug on DOS systems. It is part of the base utilities on SCO systems, but is not on my SUSE system.

So hd is hexdump. The output is the same data, but the presentation is different

pd2disp would change as follows

read discard a c 
b=`echo $a|cut -c1-2`
a=`echo $a|cut -c3-4`
d=`echo $c|cut -c1-2`
c=`echo $d|cut -c3-4`
sign=`echo $d|cut -c2`
digit=`echo $d|cut -c1`