Wednesday, January 7, 2015

Downloading a File in an Unreliable/Flaky Connection

Many of us find ourselves stuck in a place where we have a very unreliable/flaky connection and need to download a file urgently. Most likely you don't have an external download manager (those were popular in age of IE 6), and using a browser to download restarts the download from beginning every time. With a lot of luck you hope the download is successful this time. I went through the same when I spent my New Year holidays with family in a not so connected to internet part of India.

Obviously, one such solution that props to mind is using curl with "-C" continue the download flag. So using curl your command is going to look like

curl -L -O http://xyz.url

and when the download has failed, switch over to command

curl -L -O -C - http://xyz.url

But this have another problem. You have to constantly monitor the download and launch the command as soon as it craps. Curl helps you by returning an error exit value if the download was not successful and otherwise. Wish there was a command to relaunch it based on the exit flag. Since there is none, ruby can come to your rescue. We can write a small ruby script to do just that. The ruby script looks like

ruby -e "while(\!system(\"curl -L -O -C - http://xyz.url\")); end"

Hope this helps. Happy New Year !

16 comments:

  1. Another interesting information,thanks for sharing that valuable information.I can easily understand all given information.It is more helpful information.
    ios training

    ReplyDelete
  2. Fantastic write-up together with excellent website,Outbound Calling App I enjoy these kinds of challenging content articles keep this specific somebody.

    ReplyDelete

  3. This content creates a new hope and inspiration with in me. Thanks for sharing article like this. The way you have stated everything above is quite awesome. Keep blogging like this. Thanks.


    SAP training in Chennai

    ReplyDelete

  4. First is to thank you for all this informative posts you give us for free; i bet all of us are happy.
    Such a great idea of yours! You have been a big help for me. Thanks a lot. more post for interesting topic. Great!

    SAP training in Chennai

    ReplyDelete
  5. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks!


    SAP training in Chennai

    ReplyDelete

  6. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.

    SAP training in Chennai

    ReplyDelete
  7. This topic has always been one of my favorite subjects to read about. I have found your post to be very rousing and full of good information. I will check your other articles shortly.
    Go Viral

    ReplyDelete

  8. Great and useful article. Creating content regularly is very tough. Your points are motivated me to move on.


    SEO Company in Chennai

    ReplyDelete
  9. Very well said. Yeah, speaking about IT and keeping our planet green. You should definitely do a research about data room providers. It's very convenient to store your documents online.

    ReplyDelete
  10. This is a really good read for me. Must agree that you are one of the coolest blogger I ever saw. Thanks for posting this useful information. This was just what I was on looking for. Best Browser for mac

    ReplyDelete
  11. Plenty of clicks are made on the torrent websites by many people round the world to download the favorite torrents. VPN for omegle.com

    ReplyDelete
  12. Thanks for sharing such a wonderful and interesting blog with smart content..keep updating..
    Diploma Project Center in Chennai | Final Year Project Center in Chennai

    ReplyDelete
  13. Catering Corporate and Business Events Thanks for sharing the article. Keep updating more with us.

    ReplyDelete