BASH scripting - Preventing wget messed downloaded files

hello.
How can I detect within script, that the downloaded file had not a correct size.

linux:~ # wget --limit-rate=20k  --ignore-length  -O  /Software_Downloaded/MULTIMEDIA_ADDON/skype-4.1.0.20-suse.i586.rpm   http://www.skype.com/en/download-skype/skype-for-linux/downloading/?type=suse32/skype-4.1.0.20-suse.i586.rpm
--2013-06-15 15:43:44--  http://www.skype.com/en/download-skype/skype-for-linux/downloading/?type=suse32/skype-4.1.0.20-suse.i586.rpm
Resolving www.skype.com (www.skype.com)... 91.190.216.12
Connecting to www.skype.com (www.skype.com)|91.190.216.12|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: ignored [text/html]
Saving to: `/004_SOFTWARE/MULTIMEDIA_ADDON/skype-4.1.0.20-suse.i586.rpm'

    [    <=>                                                           ] 22,246      20.8K/s   in 1.0s    

But the file size file is 22M and only 22K is downloaded.
Using or not "--ignore-length" and/or "--limite-rate" is not helping.

Help is welcome.

What about checking the exit status of the wget command?
I suppose that it should be different than 0, when wget is not able to download the complete file.

wget is actually downloading a "Thank you for downloading Skype" page (you can view the downloaded file in a Web Browser). You will need to find a direct download link, or download the file manually (assuming there's no way to wget can work around this, which I'm not aware of).

1 Like

It is more complicated.
If I put the full address in my browser, I get 2 pop-up, One with the thanks screen, One with the open/save app ( open with ark in my case ).

If I click on the save option, I do not download the full file, only a partial copy. In that case I can verify the size of the file.

This arise sometimes on some kind of internet site.

This is the reason why I post this question.

That annoying website is using javascript to launch a cascade of redirects.

Starting at:

Referer: http://www.skype.com/en/download-skype/skype-for-linux/downloading/?type=suse32/skype-4.1.0.20-suse.i586.rpm

Leads to:

Location: http://download.skype.com/linux/skype-4.2.0.11-suse.i586.rpm

Note that the version delivered is not the same as the version requested. They redirect to the latest version, but you can hack the Location header's URL to fetch the originally requested version.

By the way, a little time with Firefox or Chrome developer tools is very useful when diagnosing these annoyances.

Regards,
Alister

No change with the latest version :

linux:~ # wget  -O  /data_temp/skype-4.2.0.11-suse.i586.rpm   http://www.skype.com/en/download-skype/skype-for-linux/downloading/?type=suse32/skype-4.2.0.11-suse.i586.rpm
--2013-06-15 23:44:23--  http://www.skype.com/en/download-skype/skype-for-linux/downloading/?type=suse32/skype-4.2.0.11-suse.i586.rpm
Resolving www.skype.com (www.skype.com)... 91.190.216.12
Connecting to www.skype.com (www.skype.com)|91.190.216.12|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22246 (22K) [text/html]
Saving to: `/data_temp/skype-4.2.0.11-suse.i586.rpm'

100%[============================================================================================>] 22,246      --.-K/s   in 0.1s    

2013-06-15 23:44:23 (158 KB/s) - `/data_temp/skype-4.2.0.11-suse.i586.rpm' saved [22246/22246]

linux-srv:~ # 
linux-srv:~ # echo $?
0
linux-srv:~ # 

The file saved is 21,7 Kb but should be 12.2 Mb

Because the URL you're using requires the client to support JavaScript, which wget does not. My previous post provides a working URL.

Regards,
Alister