Read Binarys Problem and Linux

T

Tex

I have a program that reads a binary data file in Unix and works just
fine, however when I tried it in Linux the read and unpack commands did
not give me the same answer. I am trying to simply read a short
integer. In Unix, the $nscan is around 20000, in linux it is a huge
number or even negative. I belive that the problem has to do with
bigendian vs littleendian, but when I try different combinations of
unpack options nothing works.
Thanks
tex

open(F, "$filein") or die "Unable to open file";
binmode(F);
read(F,$packscans, 4);
$nscan = unpack("i*",$packscans);
 
J

Josef Moellers

Tex said:
I have a program that reads a binary data file in Unix and works just
fine, however when I tried it in Linux the read and unpack commands did
not give me the same answer. I am trying to simply read a short
integer. In Unix, the $nscan is around 20000, in linux it is a huge
number or even negative. I belive that the problem has to do with
bigendian vs littleendian, but when I try different combinations of
unpack options nothing works.
Thanks
tex

open(F, "$filein") or die "Unable to open file";
binmode(F);
read(F,$packscans, 4);
$nscan = unpack("i*",$packscans);

Can you post the output of 'dd if=<file> bs=4 count=1 | OD -TXc'?
WRT endianness: what is the processor of the Unix box and what is Linux
running on?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top