getting info on remote files

Sick Monkey sickcodemonkey at gmail.com
Mon Feb 26 16:06:25 EST 2007


You should use os.popen() instead of os.system.

os.popen() will return a file-like object that is connected to the stdout of
the system command; you can then use that object's read()/readlines()
method(s) to assign that output to a Python variable.

http://docs.python.org/lib/module-popen2.html


On 26 Feb 2007 12:54:39 -0800, gabriel.altay at gmail.com <
gabriel.altay at gmail.com> wrote:
>
> 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
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070226/177affc1/attachment.html>


More information about the Python-list mailing list