From: Michael Maloney on
Trying to use the File and Dir classes on remote directories with no
luck whatsoever. Here's what I want to do:

1. Put a bunch of files into a folder on an FTP server. This could be
anywhere.

2. SSH/SFTP/FTP/whatever into that folder (none of these have worked for
me thus far).

3. Use the Ruby File and Dir classes to operate on these files.

The main problem seems to be that if you use any of the Net:: stuff from
the standard library, you can do some stuff with the related File and
Dir utilities, but you're not actually working with the files themselves
as you would in the local environment.

Is there a way to access files directly on remote servers the way you
can in the local environment? Can I get into a remote server from my
local machine and do things like File.ctime(my_remote_file) ?

Thanks in advance.
--
Posted via http://www.ruby-forum.com/.

From: Brian Candler on
Michael Maloney wrote:
> Is there a way to access files directly on remote servers the way you
> can in the local environment? Can I get into a remote server from my
> local machine and do things like File.ctime(my_remote_file) ?

Short answer: no.

Long answer: Ruby's Dir and File classes just sit on top of the
file/directory operations provided by the underlying operating system.
For example, Dir.pwd and Dir.chdir refer to the process's (local)
current working directory.

However, on some systems, if you install the right tools, you may be
able to 'mount' a remote FTP or SFTP server as if it were a local
filesystem, and then you can traverse that.

In Linux, "FUSE" allows people to write modules which do this. See
http://en.wikipedia.org/wiki/Filesystem_in_Userspace
and follow the links to FTPFS, SSHFS etc.

Supplementary answer: it's also possible to abstract away local vs
remote file operations to some degree, see for example open-uri.rb in
the standard library. As far as I know, this hasn't been done to the
level you are seeking. But feel free to have a go at implementing it
yourself :-) You may find that you are stumped by the limited support
for ctime / chmod / chown etc by protocols like FTP.
--
Posted via http://www.ruby-forum.com/.

From: Caleb Clausen on
On 7/13/10, Brian Candler <b.candler(a)pobox.com> wrote:
> Michael Maloney wrote:
>> Is there a way to access files directly on remote servers the way you
>> can in the local environment? Can I get into a remote server from my
>> local machine and do things like File.ctime(my_remote_file) ?
>
> Short answer: no.
>
> Long answer: Ruby's Dir and File classes just sit on top of the
> file/directory operations provided by the underlying operating system.
> For example, Dir.pwd and Dir.chdir refer to the process's (local)
> current working directory.
>
> However, on some systems, if you install the right tools, you may be
> able to 'mount' a remote FTP or SFTP server as if it were a local
> filesystem, and then you can traverse that.
>
> In Linux, "FUSE" allows people to write modules which do this. See
> http://en.wikipedia.org/wiki/Filesystem_in_Userspace
> and follow the links to FTPFS, SSHFS etc.
>
> Supplementary answer: it's also possible to abstract away local vs
> remote file operations to some degree, see for example open-uri.rb in
> the standard library. As far as I know, this hasn't been done to the
> level you are seeking. But feel free to have a go at implementing it
> yourself :-) You may find that you are stumped by the limited support
> for ctime / chmod / chown etc by protocols like FTP.

Or you can use a network file system such as nfs or samba, which makes
remote files appear local to all programs on your computer.

From: Hassan Schroeder on
On Mon, Jul 12, 2010 at 8:40 PM, Michael Maloney <maloney.mc(a)gmail.com> wrote:
> Trying to use the File and Dir classes on remote directories with no
> luck whatsoever.

You might want to look at <http://rush.heroku.com/>

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder(a)gmail.com
twitter: @hassan