LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-03-2009, 03:26 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Concurrently Running dd and md5sum Commands


Is there a way to merge the following two commands?

Code:
dd if=$DEVNODE of=$TMPDIR/$FILENAME bs=2048 conv=sync,notrunc

MD5SUMDISK="`dd if=$DEVNODE | md5sum | awk '{print $1}'`"
My goal is to run the dd command only once yet concurrently retrieve the md5sum. The disk md5sum is then later compared to the disk image md5sum.

Running dd twice is doable but time consuming.

P.S. I 'm not trying to concatentate the two commands on one line using the '&&' parameter. I'm trying to run dd only once.

Thanks again.
 
Old 04-03-2009, 03:37 PM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
See here:
http://www.linuxquestions.org/questi...8/#post3458795

Another option is the check program, it's also in the above thread.
 
Old 04-03-2009, 03:54 PM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,911

Rep: Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030
Hmm, the problem you'll have is that should your input file not be an exact multiple of your blocksize, the conv=sync will pad the end of output file as it passes through dd. This will mean that your md5sum will differ from a md5sum of the input (the two files will be of different sizes).

If you don't need the conv=sync then you should be able generate a md5sum and do the dd at the same time with something along the lines of:
Code:
md5sum <(dd if=infile | tee -f ouputfile)
Note: I've not got access to my linux box at the moment so I'm unable to verify if this is valid or not, but I think it'll work.
 
Old 04-03-2009, 05:06 PM   #4
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Quote:
md5sum <(dd if=infile | tee -f outputfile)
The tee command. Sounds useful!

The basic command seems to succeed without the -f option --- I could find no -f option in the tee man page and I received an error message with -f.

Seems to work but is the md5sum output that of infile or outputfile? The md5sum output is from /dev/fd/63.

Similarly:

MD5SUMDISK="`dd if=$DEVNODE | tee $FILENAME | md5sum | awk '{print $1}'`"

Because tee splits the output, I don't know which MD5SUM is being reported.


Last edited by Woodsman; 04-03-2009 at 05:12 PM.
 
Old 04-03-2009, 05:15 PM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,911

Rep: Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030Reputation: 5030
Quote:
Originally Posted by Woodsman View Post
The tee command. Sounds useful!

The basic command seems to succeed without the -f option --- I could find no -f option in the tee man page and I received an error message with -f.

Seems to work but is the md5sum output that of infile or outputfile? The md5sum output is from /dev/fd/63.
In that command it would be the md5sum of the stdout output of the tee, which should be the same as the stdout of the dd. though without the conv=sync it should be identical to the input.

And yes, you're quite right, It appears I made the -f up. Been a while since I've used tee. Sorry 'bout that.

edit: oh, and the <( ) shell syntax generates a fifo/named pipe, which explains the wierd /dev/fd name. You'll need to code your script to replace that with the name of the output file on the tee if you store the output of the md5sum for later use.

Last edited by GazL; 04-03-2009 at 05:19 PM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Preventing multiple instances of a shell script from running concurrently Dave Lerner Programming 17 04-21-2020 12:53 PM
Preventing processes running concurrently - using ps TomCruise2002 Linux - General 1 03-21-2007 01:10 PM
Running Commands blazted Linux - Newbie 6 11-13-2004 03:49 PM
running commands ./ ?? greendemon Linux - Newbie 4 08-04-2003 09:54 AM
Running commands linuxnewbie001 Linux - Newbie 6 08-01-2003 04:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration