Hi!
Is it possible to download files from an ftp-server through a
proxy-server, in a ruby-script? If so, do you have an example or url to
api specification?
Cheers, Kristian.
Hi!
Is it possible to download files from an ftp-server through a
proxy-server, in a ruby-script? If so, do you have an example or url to
api specification?
Cheers, Kristian.
Hi!
Is it possible to download files from an ftp-server through a
proxy-server, in a ruby-script? If so, do you have an example or url to
api specification?
from the pickaxe’s doc for Net::FTP
aSession.connect( host, port=FTP_PORT )
Establishes an FTP connection to host, optionally overriding the
default port. If the environment variable SOCKS_SERVER is set, sets up
the connection through a SOCKS proxy. Raises an exception (typically
Errno::ECONNREFUSED) if the connection cannot be established
il Mon, 10 Nov 2003 22:36:35 +0100, Kristian Sørensen ks@cs.auc.dk ha scritto::
Cheers, Kristian.
Hi, thanks for your answer
I saw the below part, but was not clear enough in my question:
Is it possible to do something like the browsers, without socks?
gabriele renzi wrote:
il Mon, 10 Nov 2003 22:36:35 +0100, Kristian Sørensen ks@cs.auc.dk > ha scritto::
Hi!
Is it possible to download files from an ftp-server through a
proxy-server, in a ruby-script? If so, do you have an example or url to
api specification?from the pickaxe’s doc for Net::FTP
aSession.connect( host, port=FTP_PORT )
Establishes an FTP connection to host, optionally overriding the
default port. If the environment variable SOCKS_SERVER is set, sets up
the connection through a SOCKS proxy. Raises an exception (typically
Errno::ECONNREFUSED) if the connection cannot be establishedCheers, Kristian.
Kristian Sørensen wrote:
- Internet browsers is able to use e.g. regular squid proxy to make ftp
connections. That was what I was after. It isn’t too many places a socks
server is available (not that I know of anyway
You make an HTTP proxy request, using an FTP URL.
An HTTP proxy request differs from a normal HTTP request
in that the GET line contains “http://host.domain” at the
start of the URL string. Just replace the http with ftp,
add whatever username/password you need, and Squid will
do the FTP for you. The request line looks like:
GET ftp://user:password@host.domain/pub/some_file HTTP/1.0
I haven’t tried to do this with Ruby’s http though…
Clifford.
Clifford Heath wrote:
Kristian Sørensen wrote:
- Internet browsers is able to use e.g. regular squid proxy to make
ftp connections. That was what I was after. It isn’t too many places a
socks server is available (not that I know of anywayYou make an HTTP proxy request, using an FTP URL.
An HTTP proxy request differs from a normal HTTP request
in that the GET line contains “http://host.domain” at the
start of the URL string. Just replace the http with ftp,
add whatever username/password you need, and Squid will
do the FTP for you. The request line looks like:GET ftp://user:password@host.domain/pub/some_file HTTP/1.0
Okay, that’s sounds easy, but I can’t get it to work. Can you complete a
ftp-download example?
I have tried with the following (including variants of it), but can’t
get it to work:
#!/usr/bin/env ruby
require ‘net/http’
Net::HTTP.start(‘ftp://anonymous:anonymous@ftp.sunsite.dk’, 21) { |http|
response, data = http.get(‘/pub/gnu/mc/mc-4.5.55.tar.gz’, nil)
initialize': getaddrinfo: Name or service not known (SocketError) from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:84:in
new’connect' from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:83:in
timeout’timeout' from /pack/ruby-1.8.0/lib/ruby/1.8/net/protocol.rb:83:in
connect’initialize' from /pack/ruby-1.8.0/lib/ruby/1.8/net/http.rb:422:in
open’do_start' from /pack/ruby-1.8.0/lib/ruby/1.8/net/http.rb:409:in
start’/KS
Kristian Sørensen wrote:
Okay, that’s sounds easy, but I can’t get it to work. Can you complete a
ftp-download example?
I don’t know if it’s possible with Ruby 1.6. Your example doesn’t work
because the “start” method expects a DNS-resolvable name, but you
gave it “ftp://anonymous:anonymous@ftp.sunsite.dk”.
I don’t recall seeing this in 1.6, but 1.8 has Net::HTTP.Proxy:
#! /usr/bin/env ruby
require ‘net/http’
Net::HTTP::Proxy(‘webproxy.local’, 3128).start(‘ftp.netscape.com’) { |http|
response, data = http.get(‘/’)
$stdout.write(data)
}
Works a treat here.
Tried this?
Net::HTTP.start(‘the.proxy.com’, 80) { |http|
response, data = http.get(‘ftp://anonymous:anonymous@ftp.sunsite.dk" +
"/pub/gnu/mc/mc-4.5.55.tar.gz’, nil)
On Mon, Nov 17, 2003 at 10:24:38AM +0900, Kristian Sørensen wrote:
I have tried with the following (including variants of it), but can’t
get it to work:#!/usr/bin/env ruby
require ‘net/http’Net::HTTP.start(‘ftp://anonymous:anonymous@ftp.sunsite.dk’, 21) { |http|
response, data = http.get(‘/pub/gnu/mc/mc-4.5.55.tar.gz’, nil)File.open(“mc.tgz”, “wb”) { |f|
f.write(data)
}
}
–
Thomas
beast@system-tnt.dk
Clifford Heath wrote:
Kristian Sørensen wrote:
Okay, that’s sounds easy, but I can’t get it to work. Can you complete
a ftp-download example?I don’t know if it’s possible with Ruby 1.6. Your example doesn’t work
because the “start” method expects a DNS-resolvable name, but you
gave it “ftp://anonymous:anonymous@ftp.sunsite.dk”.I don’t recall seeing this in 1.6, but 1.8 has Net::HTTP.Proxy:
#! /usr/bin/env ruby
require ‘net/http’Net::HTTP::Proxy(‘webproxy.local’, 3128).start(‘ftp.netscape.com’) { |http|
response, data = http.get(‘/’)
$stdout.write(data)
}Works a treat here.
That did the job. Thanks a lot!!
KS.
Clifford Heath wrote:
Kristian Sørensen wrote:
Okay, that’s sounds easy, but I can’t get it to work. Can you complete
a ftp-download example?I don’t know if it’s possible with Ruby 1.6. Your example doesn’t work
because the “start” method expects a DNS-resolvable name, but you
gave it “ftp://anonymous:anonymous@ftp.sunsite.dk”.I don’t recall seeing this in 1.6, but 1.8 has Net::HTTP.Proxy:
#! /usr/bin/env ruby
require ‘net/http’Net::HTTP::Proxy(‘webproxy.local’, 3128).start(‘ftp.netscape.com’) { |http|
response, data = http.get(‘/’)
$stdout.write(data)
}Works a treat here.
Hi again!
As I wrote earlier, it seems to work nicely. However the reason for
this, is that a webserver is also providing an interface to
ftp.netscape.com. The request created by Ruby is an http request on port
80, not a ftp request.
Fortunately the all-over solution just poped into my head: use wget…
wget --passive-ftp #{server}:#{pathAndFile}
Cheers, KS.
Kristian Sørensen wrote:
As I wrote earlier, it seems to work nicely. However the reason for
this, is that a webserver is also providing an interface to
ftp.netscape.com.
Ouch, you’re right! I should have realised that my example didn’t
actually request ftp protocol.
Fortunately the all-over solution just poped into my head: use wget…
Yup, but that’s pretty sucky. Will see if I can see how to extend
Net::HTTP to do the right thing. The problem is in ‘module ProxyDelta’,
the edit_class method, which has http:// hard-wired, sigh.
Thomas Fini Hansen wrote:
Tried this?
Nice one, thanks. I haven’t looked to see how it works, but it seems to.
Clifford Heath wrote:
Kristian Sørensen wrote:
As I wrote earlier, it seems to work nicely. However the reason for
this, is that a webserver is also providing an interface to
ftp.netscape.com.Ouch, you’re right! I should have realised that my example didn’t
actually request ftp protocol.Fortunately the all-over solution just poped into my head: use wget…
Yup, but that’s pretty sucky. Will see if I can see how to extend
Net::HTTP to do the right thing. The problem is in ‘module ProxyDelta’,
the edit_class method, which has http:// hard-wired, sigh.
I would not say that wget sucks … ?But - builtin ruby support would
be nice though
Cheers, KS.
There’s a ruby-curl, which might help (or might not - it’s pre-alpha
according to the webpage).
http://rox-ruby.sourceforge.net/cms.php/curl
martin
Clifford Heath cjh_nospam@managesoft.com wrote:
Kristian S?rensen wrote:
Fortunately the all-over solution just poped into my head: use wget…
Yup, but that’s pretty sucky. Will see if I can see how to extend
Net::HTTP to do the right thing. The problem is in ‘module ProxyDelta’,
the edit_class method, which has http:// hard-wired, sigh.
It has a number of problems, I managed to seriously wedge a web server
while trying to access it with the curl library. Not recommended.
– Matt
Boredom isn’t the root of all evil, but it tries.
On Mon, 17 Nov 2003, Martin DeMello wrote:
There’s a ruby-curl, which might help (or might not - it’s pre-alpha
according to the webpage).