<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>/home/spsneo/blog &#187; proxy</title>
	<atom:link href="http://spsneo.com/blog/category/proxy/feed/" rel="self" type="application/rss+xml" />
	<link>http://spsneo.com/blog</link>
	<description>Trying to move every bit to cloud.</description>
	<lastBuildDate>Fri, 19 Aug 2011 16:43:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Download Files Larger Than The Download Limit</title>
		<link>http://spsneo.com/blog/2008/08/18/download-files-larger-than-the-download-limit/</link>
		<comments>http://spsneo.com/blog/2008/08/18/download-files-larger-than-the-download-limit/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 18:11:11 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[curl]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[download]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=34</guid>
		<description><![CDATA[Yesterday I had to download a file of size 232 MB. As I connect to the Internet via proxy and the authorities have restricted the file size download limit to 150 MB, I had to find some alternative. Similar scenarios &#8230; <a href="http://spsneo.com/blog/2008/08/18/download-files-larger-than-the-download-limit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I had to download a file of size 232 MB. As I connect to the Internet via proxy and the authorities have restricted the file size download limit to 150 MB, I had to find some alternative. Similar scenarios are there in almost all Educational Institutions.</p>
<p>I was searching for the solution, somebody told me about JGet (a Multithreaded Java Software), but it hogs up a lot of system resources. I was in search of an alternate solution, then somebody on ##linux in irc.freenode.net told me about curl. Though I had heard of it earlier as well and I used it to automate web browsing like posting form data etc. But this time when I went through the man pages of curl, I realized how powerful is curl.</p>
<p>There are hundreds of options for CURL. I will just demonstrate you the one option which can help you download files of almost any size.</p>
<p>Lets start off&#8230;</p>
<p>In this example I am trying to download 32 Bit Fedora Live CD iso image. In this example, what we will do is download a part of file in one connection. After downloading all files we will concatenate them. This is what almost any Download manager software does.</p>
<p>To download a part of file theres an option <code>-r/ --range</code> available in curl which lets us specify the range of bytes of the file to be downloaded.</p>
<p>Range can be specified in following ways :<br />
<code> curl -r 0-499 </code><br />
This specifies to download first 500 bytes<br />
<code> curl -r 500-999 </code><br />
This specifies to download bytes starting from 500 to 999.<br />
<code> curl -r -500 </code><br />
specifies to download last 500 bytes.<br />
<code> curl -r 500- </code><br />
specifies to download the bytes from offset 500 and forward</p>
<p>There are few more options. Check out the man pages. ( I have copied the simple options here).</p>
<p>Now here I have to download Fedora live CD iso which is 691 MB in size. So, I will download 100 MB in each connection, like this:<br />
<code> curl -# -r 0-99999999 -o fedora.iso.part1 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso  &amp;</code></p>
<p><code> curl -# -r 100000000-199999999 -o fedora.iso.part2 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso &amp; </code></p>
<p><code> curl -# -r 200000000-299999999 -o fedora.iso.part3 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso &amp;</code></p>
<p><code> curl -# -r 300000000-399999999 -o fedora.iso.part4 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso &amp;</code></p>
<p><code> curl -# -r 400000000-499999999 -o fedora.iso.part5 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso &amp;</code></p>
<p><code> curl -# -r 500000000-599999999 -o fedora.iso.part6 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso &amp;</code></p>
<p><code> curl -# -r 600000000- -o fedora.iso.part7 http://download.fedoraproject.org/pub/fedora/linux/releases/9/Live/i686/Fedora-9-i686-Live.iso &amp;</code></p>
<p>In the above code -# is to suppress the details of progress meter. You can ignore this option.</p>
<p>After all the files are downloaded, we need to concatenate them. This is quite simple.</p>
<p><code> $ cat fedora.iso.part? &gt; fedora-9-live.iso</code><br />
And your live CD iso image is ready as fedora-9-live.iso<br />
To verify the file has been downloaded and concatenated correctly you may verify the checksums before burning it to a CD/DVD.</p>
<p>This process could be automated if somehow by a simple shell script if we could get the file size before starting the downloaded. To accomplish this, I once again went through the man pages. And I found a useful option <code> -I/ --head </code>. This option fetches the HTTP-header  only. One can easily get the file size as Content-Length from the HTTP headers. But, when I tried this through proxy servers I got a X-Squid-Error: ERR_TOO_BIG , so couldn&#8217;t determine the correct file size. And hence I am unable to automate the process. Anybody, any help ?? (please post it as comment).</p>
<p>Happy Downloading !!</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2008/08/18/download-files-larger-than-the-download-limit/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

