Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Read Binarys Problem and Linux

Reply
Thread Tools

Read Binarys Problem and Linux

 
 
Tex
Guest
Posts: n/a
 
      06-15-2005
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);

 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      06-16-2005
Tex wrote:
> 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?

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
native binarys Ben Aroia Ruby 1 02-28-2008 09:52 AM
Re: Is Netscape Leaving Firefox Behind on GNU/Linux? THE LINUX PROPAGANDA MACHINE CONTINUES. FIREFOX IGNORING LINUX............. traci.manicotti@gmail.com Computer Support 2 10-20-2007 02:12 PM
Linux... yeah linux.. Linux Have a nice cup of pee NZ Computing 19 04-17-2006 10:16 AM
SSH to Linux and Linux to PIX Ste Cisco 1 08-29-2004 10:50 PM
Linux and vpnclient-linux-4.0.3.B-k9 install problem JSH Cisco 0 06-07-2004 03:56 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57