On Sep 17, 2010, at 2:02 PM, J=E9r=E9my Lecour wrote:

> I needed to download a file from a FTP server, with OpenURI and I've =
found that it is not possible to do it with authentication.
>=20
> There is an option in the OpenURI open method to use a =
username/password but it is not used in FTP connection, the =
username/password for FTP is always set to anonymous/_nil_.

OpenURI is just a wrapper around some clever URI parsing and URI seems =
to support it just fine:

>> require "uri"
=3D> true
>> u =3D URI.parse("http://user:pass / server.com/")
=3D> #<URI::HTTP:0x1007180f8 URL:http://user:pass / server.com/>
>> u.userinfo
=3D> "user:pass"
>> u.host
=3D> "server.com"
>> u =3D URI.parse("ftp://user:pass / server.com/")
=3D> #<URI::FTP:0x10070e2b0 URL:ftp://user:pass / server.com/>
>> u.userinfo
=3D> "user:pass"
>> u.host
=3D> "server.com"

Just add it to the server URL and I think you are all set.

James Edward Gray II=