Robert Klemme
11/2/2006 3:33:00 PM
On 02.11.2006 16:00, greg wrote:
> What is the fastest way to do a recursive file glob on a remote server?
> Keep in mind that I want to do some filtering based on the directory
> name, file properties, and file extensions.
> (I want to copy these files, but I assume once I have the list, that
> using Net::FTP will be trivial)
>
> I am concerned that just using ftp.chdir and ftp.list will be slow.
> Perhaps there is a faster way using Net:SSH. I had an idea to try to
> run a ruby program on the server (ruby is installed on the remote
> server)
> cmd = "ruby -e ' #{ File.read( ruby_glob_program ) } ' "
That would rather be something like
ruby -e 'puts Dir["base/**/*.txt"]'
ruby -r find -e 'Find.find("base") {|f| puts f if /\.txt$/ =~ f }'
> Net::SSH.start(SERVER, :username => u, :password => p) do |session|
> input, output, error = session.process.popen3( cmd )
However, if you just want to find files fast and then copy them, a
combination of ssh, find, xargs, cp, tar,... might be more efficient.
Kind regards
robert