Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

getting info on remote files


hello everyone,

Im trying to write some python code that will return information (file
size, last modified ...) about files on a remote computer that I have
'no password' ssh access to.  Ive been able to write code that logs on
to remote computers and I can issue a command using,

os.system(ssh blah.blah.blah.org "ls -l myfile")

but how do I store the information returned by the ls command into a
variable.  The primary goal of this is to
1. check file size on remote computer
2. scp file to local computer
3. make sure file size of copy and original are the same

any suggestions would be appreciated

thanks
gabe

Why not just use rsync across the ssh tunnel to synchronize the remote
file to local file?  This works great and you don't have to do much.

-Larry

On 26 Feb 2007 12:54:39 -0800, gabriel.al@gmail.com declaimed the
following in comp.lang.python:

> os.system(ssh blah.blah.blah.org "ls -l myfile")

> but how do I store the information returned by the ls command into a
> variable.  The primary goal of this is to

        Short answer: Don't use os.system()

        Longer answer: os.system() is a fire&forget operation; all it
typically returns is a completion status which may or may not be useful.
Investigate the various functions in the subprocess module WRT piping
output...
--
        Wulfraed        Dennis Lee Bieber               KD6MOG
        wlfr@ix.netcom.com              wulfr@bestiaria.com
                HTTP://wlfraed.home.netcom.com/
        (Bestiaria Support Staff:               web-a@bestiaria.com)
                HTTP://www.bestiaria.com/

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc