# Ruby WGet

**URL:** <https://www.ruby-forum.com/t/ruby-wget/165130>\
**Category:** Ruby\
**Created:** [April 9, 2009, 12:00pm UTC](https://www.ruby-forum.com/t/ruby-wget/165130 "2009-04-09T12:00:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 9, 2009, 12:00pm UTC](https://www.ruby-forum.com/t/ruby-wget/165130/1 "2009-04-09T12:00:49Z")

</div>

Hi,

I would need a ruby “wget version” which works on linux and windows.

I would like to feed it an URL to a .tar.bz2 or .zip or .tar.gz file and  
have it download. That’s what it basically should do.

Right now I use

system 'wget '+the\_url

which does not work on windows easily (but will work on pretty much all  
the linuxes out there)

I once wrote a minimal ruby wget wrapper but it has some problems as the  
code is years old and messy 😕 so I was wondering if anyone is using  
some ruby-wget thing?

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 9, 2009, 12:25pm UTC](https://www.ruby-forum.com/t/ruby-wget/165130/2 "2009-04-09T12:25:39Z")

</div>

On 09.04.2009 12:00, Marc H. wrote:

> I would need a ruby “wget version” which works on linux and windows.
> 
> I would like to feed it an URL to a .tar.bz2 or .zip or .tar.gz file and  
> have it download. That’s what it basically should do.

> I once wrote a minimal ruby wget wrapper but it has some problems as the  
> code is years old and messy 😕 so I was wondering if anyone is using  
> some ruby-wget thing?

It seems Net::HTTP is everything you need, especially since you just  
want to download a single file and did not mention other requirements.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 9, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/ruby-wget/165130/3 "2009-04-09T12:29:46Z")

</div>

On Thu, Apr 9, 2009 at 11:00 AM, Marc H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,
> 
> I would need a ruby “wget version” which works on linux and windows.
> 
> I would like to feed it an URL to a .tar.bz2 or .zip or .tar.gz file and  
> have it download. That’s what it basically should do.

Net::HTTP should be adequate, no?

Ben

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 9, 2009, 2:47pm UTC](https://www.ruby-forum.com/t/ruby-wget/165130/4 "2009-04-09T14:47:08Z")

</div>

I’d suggest using openuri – it’s a lot more flexible than net::http.

Not to toot my own horn, but I’ve a version of cat which opens uri’s,  
files, etc…, which you might consider basing your code upon – it’s  
at:

> **[cat on steroids (or cat on a hot ruby roof)](http://matthewkwilliams.com/index.php/2008/09/10/cat-on-steroids/)**
>
> I got to thinking about SuperIO and how it could be used as a swiss army chainsaw to open files, whereever they might be on the net.  From there, my fevered mind got to thinking about cat and how t…

(and a followup at)

> **[universal cat redux](http://matthewkwilliams.com/index.php/2008/09/11/universal-cat-redux/)**
>
> I have a neglectful relationship with inject. That is, I neglect to remember that it exists, having worked for so long with other languages which are “unfamiliar with the concept”. Amos…

Hope this helps,  
Matt

–  
“… if you do follow your bliss you put yourself on a kind of  
track that has been there all the while, waiting for you, and the life  
that you ought to be living is the one you are living. When you can  
see that, you begin to meet people who are in your field of bliss, and  
they open doors to you. I say, follow your bliss and don’t be afraid,  
and doors will open where you didn’t know they were going to be.” –  
Joseph Campbell
