views:

17

answers:

0

If I have a remote SFTP server with a folder full of files on it that I want to operate on with Ruby's Dir and File classes, is there a way to do that through the net/ssh and net/sftp libraries?

I know that net/sftp has a few Dir and File utilities strapped to it, but unfortunately they're not the ones I need. I need

File.ctime(my_file)

specifically.

If I open an ssh/sftp connection like so

Net:SSH.start('server', 'username', :password => 'password') do |ssh|
  ssh.sftp.connect do |sftp|
    Dir.foreach(".") do |file|
      puts file
      # or do File.whatever(file)
    end
  end
end

The Dir class responds, but does its thing in whatever directory I'm in on my local machine and not on the remote.

Any ideas?