5

I try to use wget to download this but failed.

https://code.ros.org/trac/wg-ros-pkg/raw-attachment/ticket/5069/rein_cmakelists2.patch

  sam@sam:/media/Data/code/ros/recognition/rein$ wget https://code.ros.org/trac/wg-ros-pkg/raw-attachment/ticket/5069/rein_cmakelists2.patch
  --2012-10-04 16:29:30--  https://code.ros.org/trac/wg-ros-pkg/raw-attachment/ticket/5069/rein_cmakelists2.patch
  Resolving code.ros.org (code.ros.org)... 157.22.19.21
  Connecting to code.ros.org (code.ros.org)|157.22.19.21|:443... connected.
  HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
  Retrying.

  --2012-10-04 16:29:32--  (try: 2)  https://code.ros.org/trac/wg-ros-pkg/raw-attachment/ticket/5069/rein_cmakelists2.patch
  sam@sam:/media/Data/code/ros/recognition/rein$                                                                        

But I can use firefox to download.

How to download this kind of file in wget?

Thank you~

4
  • Works here, at least in my case (Serbia) Oct 4, 2012 at 8:52
  • Check this lwn.net/Articles/92727 article. Turning off TCP window scaling might help you. echo 0 > /proc/sys/net/ipv4/tcp_window_scaling
    – devav2
    Oct 4, 2012 at 12:17
  • Permission denied when I run that command. What to do next? Thank you~
    – sam
    Oct 8, 2012 at 2:17
  • in fact i use axel instead, but also usually cannot download files that small (1.2kb).
    – user47206
    Jun 25, 2013 at 22:34

2 Answers 2

4

Some websites or servers block wget (and similar tools) in order to only allow downloads from a browser. You can trick the website into thinking that you are an actual browser. There are many examples available on google. Here is a particularly complete one taken from askapache. To find alternatives just google wget pretend browser.

wget 
  --referer="http://www.google.com" 
  --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" 
  --header="Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" 
  --header="Accept-Language: en-us,en;q=0.5" 
  --header="Accept-Encoding: gzip,deflate"
  --header="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" 
  --header="Keep-Alive: 300" 
  -dnv [THE URL; in your case: https://code.ros.org/trac/wg-ros-pkg/raw-attachment]/ticket/5069/rein_cmakelists2.patch

This is one command, though I put it on several lines to increase readability. You can make it an alias to make it easier to use.

1

This may due to the site use ticket along with cookies for downloading (some other methods too). So when using wget it's necessary to load cookies file as well as other option like user agent, etc.

For example: "wget" --trust-server-names -c -O jre-7u21-linux-x64.rpm --directory-prefix=/home/totti/Downloads --referer= http://java.com/en/download/linux_manual.jsp \?locale=en --load-cookies=/tmp/flashgot.7gavixy1.default/cookies --header=Cookie:s_vi=[CS]v1\|28BA8A90050109CA-6000011540153427[CE]\;\ --user-agent=Mozilla/5.0\ (X11\;\ Ubuntu\;\ Linux\ i686\;\ rv:16.0)\ Gecko/20100101\ Firefox/16.0 http://sdlc-esd.sun.com/ESD6/JSCDL/jdk/7u21-b11/jre-7u21-linux-x64.rpm \?AuthParam=1366627766_80a413ae29c4b4d2e12ac7e334d61847\&GroupName=JSC\&FilePath=/ESD6/JSCDL/jdk/7u21-b11/jre-7u21-linux-x64.rpm\&File=jre-7u21-linux-x64.rpm\&BHost=javadl.sun.com

This can be easily done using the firefox extension Flashgot. (pls some one a add link to it)

1
  • 2018 calling: flashgot extension no longer maintained/compatible with Firefox Apr 21, 2018 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .