FAQ
Hi I'm looking to do something like this

f = f.openfileobj(remotefileloc, localfilelikeobj)

my remote files are on a solaris box that i can access using ssh (could
prehap request othe protocols if necessary)

anyone got any ideas?

many thanks

Charlie

(ps. tried this on the python-forum but didn't seem to go on so apologies if
i'm cross posting)
--
View this message in context: http://www.nabble.com/Open-file-on-remote-linux-server-tp25531253p25531253.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Search Discussions

  • Sean DiZazzo at Sep 23, 2009 at 7:41 pm

    On Sep 23, 12:04?pm, The Bear wrote:
    Hi I'm looking to do something like this

    f = f.openfileobj(remotefileloc, localfilelikeobj)

    my remote files are on a solaris box that i can access using ssh (could
    prehap request othe protocols if necessary)

    anyone got any ideas?

    many thanks

    Charlie

    (ps. tried this on the python-forum but didn't seem to go on so apologies if
    i'm cross posting)
    --
    View this message in context:http://www.nabble.com/Open-file-on-remote-linux-server-tp25531253p255...
    Sent from the Python - python-list mailing list archive at Nabble.com.
    I don't know of any Python library that will give you that kind of
    access to a remote file over ssh. It sounds like a fun project
    though!

    If nothing else, you can install the ssh filesystem for Fuse, and just
    mount the remote filesystem as if it was local.

    ~Sean
  • Diez B. Roggisch at Sep 23, 2009 at 9:41 pm

    The Bear schrieb:
    Hi I'm looking to do something like this

    f = f.openfileobj(remotefileloc, localfilelikeobj)

    my remote files are on a solaris box that i can access using ssh (could
    prehap request othe protocols if necessary)

    anyone got any ideas?
    try paramiko. Or just use subprocess to scp and open the file locally.


    Diez
  • Martien Verbruggen at Oct 2, 2009 at 7:00 am

    On Wed, 23 Sep 2009 23:41:35 +0200, Diez B. Roggisch wrote:
    The Bear schrieb:
    Hi I'm looking to do something like this

    f = f.openfileobj(remotefileloc, localfilelikeobj)

    my remote files are on a solaris box that i can access using ssh (could
    prehap request othe protocols if necessary)

    anyone got any ideas?
    try paramiko. Or just use subprocess to scp and open the file locally.

    import paramiko

    ssh = paramiko.SSHClient()
    ssh.load_system_host_keys(os.environ['HOME'] + '/.ssh/known_hosts')
    ssh.connect('localhost')
    try:
    ftp = ssh.open_sftp()
    # To write
    fh = ftp.file('/tmp/foo.test', 'w')
    fh.write('This is a test string\nAnd this is another one')
    fh.close()
    # To read
    fh = ftp.file('/tmp/foo.test', 'r')
    for l in fh:
    print l,
    fh.close()
    finally:
    ssh.close()

    You may need to add some password handling in there (for me my
    environment takes care of that).

    Martien
    --
    Martien Verbruggen | You can't have everything, where would
    first.last at heliotrope.com.au | you put it?
  • Neil Hodgson at Sep 24, 2009 at 12:12 am

    The Bear:
    Hi I'm looking to do something like this

    f = f.openfileobj(remotefileloc, localfilelikeobj)

    my remote files are on a solaris box that i can access using ssh (could
    prehap request othe protocols if necessary)
    You could look into GIO which is a virtual file system API used in
    GTK+. I was a bit put off by it (necessarily) exposing the asynchronous
    nature of remote file operations. Its fun to write a small amount of
    asynchronous file I/O code but ensuring that all of your code handles
    all the potential problems with remote connections is tedious.

    Base library:
    http://library.gnome.org/devel/gio/stable/

    Python bindings:
    http://library.gnome.org/devel/pygobject/stable/

    Before committing to this, you should double check that these are the
    currently supported APIs. There was an earlier API GnomeVFS that has
    been deprecated for several years now and I don't follow this area closely.

    Neil

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 23, '09 at 7:04p
activeOct 2, '09 at 7:00a
posts5
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase