The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to read terminal attributes using ioctl() Sreejesh.S High Level Programming 1 05-17-2008 01:56 PM
read terminal command munnu High Level Programming 6 01-11-2007 04:56 PM
How to read lock terminal values in solaris pankajarora_12 UNIX for Dummies Questions & Answers 0 07-11-2006 10:31 AM
read from terminal rein Shell Programming and Scripting 1 10-21-2005 10:43 AM
Terminal Hungup at the time of read pkusumam Shell Programming and Scripting 1 11-30-2001 04:19 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2009
TeamUSA TeamUSA is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 17
read a .bin through terminal and output a checksum?

Hi all,

Ive been given a .bin file that I want to do a checksum on to make sure that it is consistant with what I know should be the checksum. I have tried using md5sum but it spits out a 128 bit line rather than a 32 bit line, which is what I want. Can someone help set me off in the right direction to develop a tool that will allow me to read each word in the .bin and compile a checksum together? I have never used unix before and I would like explanation on what I should do. Thanks in advance for any and all help.
  #2 (permalink)  
Old 07-02-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 967
Hi TeamUSA.

Look at cksum, or...

Perl has an excellent feature for this:

String::CRC::Cksum - Perl extension for calculating checksums in a manner compatible with the POSIX cksum program. - search.cpan.org

But I'm not quite sure why you want to "read each word and compile a checksum"
  #3 (permalink)  
Old 07-02-2009
TeamUSA TeamUSA is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 17
Hey scottn,

Thanks for sending me that. Im definitely going to take a look at it.

I dont think I explained my goals. Im still new to all this so I may have stated it wrong. Basically, I want to take a file name (with the path) as an input, and I would like the output to be a computed checksum. I believe the checksum should be a 32 bit sum of all the words I have in the bin file.

I'm going to see what that site gives me scottn but if anyone else has any solutions I'd be more than welcome to hear them. Thanks.
  #4 (permalink)  
Old 07-02-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 967
Well a simple way to include the file and the contents in the checksum would be:

Code:
(echo file1; cat file1) | cksum
Best you read up, all the same!
  #5 (permalink)  
Old 07-02-2009
TeamUSA TeamUSA is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 17
Thanks scottn. I dont exactly know where to put all of this in. Do i type this into terminal and then just hit return? I dont understand how programming in terminal works. haha thanks again.
  #6 (permalink)  
Old 07-03-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 967
You could run it from the command line as you say, or from a script.

You can program "in the terminal" exactly as you would in a script.

If your shell is /bin/ksh, for example (echo $0 to see what shell you are running), you can type ksh commands on the command line exactly as you would write them in a script.

So whether you run

Code:
(echo $PWD/file1; cat file1) | cksum
from the command line, or put it into a file and execute the file, the result is the same.

If you're very new to this you might want to avoid Perl just for now!
  #7 (permalink)  
Old 07-05-2009
TeamUSA TeamUSA is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 17
haha thanks again scottn. I really want to get Perl so im hoping to stick it out. So basically, i can type (echo $PWD/file1; cat file1) | cksum in the terminal and type in the file path where you have file1? Sorry for being so new to this.
Sponsored Links
Reply

Bookmarks

Tags
checksum

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On



All times are GMT -4. The time now is 10:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0