1

I need to perform a md5sum check after downloading a zip file. My shell script looks like this:

wget $1 -O "$5.zip" 
md5pkg=md5sum $5.zip
#perform check and other operations with md5pkg

Now, the check is performed before download completion, resulting to an error since the .zip file hasn't bean downloaded yet. What's the best approach to solve this problem?

thanks in advance.

4
  • 2
    But generally in bash it run command step by step then how its running check sum before download? Commented Mar 25, 2013 at 17:00
  • 1
    Your second line should read md5pkg=$(md5sum $5.zip), but it's not the source of your problem. Commented Mar 25, 2013 at 17:06
  • 1
    You must be putting process in backgroup using '&' Commented Mar 25, 2013 at 17:11
  • @Satish i've got to verify what you say. According to What i see in the console output, files download is completed after the attempt of md5sum check. I'll let you know. Commented Mar 26, 2013 at 9:53

1 Answer 1

1

If there is an ampersand in the value of $1, it will be parsed as the background operator, allowing the rest of your script to proceed. Quote it:

wget "$1" -O "$5.zip"
md5pkg=$( md5sum "$5.zip" )

In this case, I would expect the portion after the ampersand to be an invalid shell command and cause an error, which you don't mention. There may be other problems, but you should quote your variables in any case.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.