read a .bin through terminal and output a checksum?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers read a .bin through terminal and output a checksum?
# 1  
Old 07-02-2009
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  
Old 07-02-2009
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  
Old 07-02-2009
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  
Old 07-02-2009
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  
Old 07-02-2009
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  
Old 07-03-2009
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  
Old 07-05-2009
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

2. UNIX for Dummies Questions & Answers

What happens when i write on terminal "cat /bin/ls" ?

i all, i'm trying to understand a code, i see this line cat /bin/ls that have a strange output...can someone explain me what is it? (2 Replies)
Discussion started by: Marina2013
2 Replies

3. IP Networking

Wireshark UDP checksum bad checksum

Hello I am communicating with two devices using my computer over UDP protocol. The application is running fine. When I monitored the UDP traffic using Wireshark software, I found that there were too many Checksum errors. Please find attached the png file showing this error. I am about to... (0 Replies)
Discussion started by: AustinCann
0 Replies

4. HP-UX

errors from output /usr/bin/last

for ga016dgf -> /usr/bin/last | cut -c1-3 Invalid record size. Unable to continue ... any ideas? running on ga016dgf -> uname -a HP-UX ga016dgf B.11.31 U ia64 1246079591 unlimited-user license thank you. Video tutorial on how to use code tags in The UNIX and Linux Forums. (4 Replies)
Discussion started by: Bill L.
4 Replies

5. UNIX for Dummies Questions & Answers

Split and Rename files using Terminal and bin/bash

I have a file named Me_thread_spell.txt that I want to split into smaller files. I want it to be split in each place there is a ;;;. For example, blah blah blah ;;; blah bhlah hlabl awasnceuir asenduhfoijhacseiodnbfxasd;;; oabwcuhaweoir;;; This full file would be three separate files... (7 Replies)
Discussion started by: mschpers
7 Replies

6. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

7. Programming

read terminal command

hi how to read terminal command, just i want to read all command which write on terminal so please tell me any system call, api avilable in c for above purpose (6 Replies)
Discussion started by: munnu
6 Replies

8. Shell Programming and Scripting

read from terminal

If I do: cat file | write user I can cat a file to a users terminal. My question is, how can this user read the input and cat it into a file? I tried the reverse: read | file or read > file etc. But it didn't work. (1 Reply)
Discussion started by: rein
1 Replies

9. Shell Programming and Scripting

To alter perl /bin/date output by - 5 hours

Hello! I'm using a perl script which calls the time and date from a remote server using the line /bin/date - What is needed in this line to reduce the output time 5 hours? Thanks (2 Replies)
Discussion started by: Texan
2 Replies

10. UNIX for Dummies Questions & Answers

Standard output not redirected from /bin/sh

I have an application which has a lot of cout & cerr statements. This application also opens a log file (for eg a.log). When this application is run from the inittab file as follows /bin/sh -c " . /etc/timezone; exec /test" all the cout & cerr statements are printed in the log file... (1 Reply)
Discussion started by: soorajmu
1 Replies
Login or Register to Ask a Question