Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Open file on remote linux server

Reply
Thread Tools

Open file on remote linux server

 
 
The Bear
Guest
Posts: n/a
 
      09-23-2009

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-r...p25531253.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
 
 
 
Sean DiZazzo
Guest
Posts: n/a
 
      09-23-2009
On Sep 23, 12:04*pm, The Bear <(E-Mail Removed)> 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-r...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
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      09-23-2009
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
 
Reply With Quote
 
Neil Hodgson
Guest
Posts: n/a
 
      09-24-2009
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
 
Reply With Quote
 
Martien Verbruggen
Guest
Posts: n/a
 
      10-02-2009
On Wed, 23 Sep 2009 23:41:35 +0200,
Diez B. Roggisch <(E-Mail Removed)> 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
http://www.velocityreviews.com/forums/(E-Mail Removed) | you put it?
|
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Re: how to open a file in some application using Tkinter i am usingTKINTER to create GUI application i want to know how to open a worddocument in open office or any other applicatio Fredrik Lundh Python 1 01-09-2008 10:40 AM
Re: Is Netscape Leaving Firefox Behind on GNU/Linux? THE LINUX PROPAGANDA MACHINE CONTINUES. FIREFOX IGNORING LINUX............. traci.manicotti@gmail.com Computer Support 2 10-20-2007 02:12 PM
Linux... yeah linux.. Linux Have a nice cup of pee NZ Computing 19 04-17-2006 10:16 AM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM



Advertisments