Python's tail -f implementation for remote files

asdf asdf at asdf.com
Wed May 28 18:20:10 EDT 2008


Basically what i want to do is to read a file
that is being constantly appended to but which
is located on a remote server.
I found this for doing BASH's tail -f in python:

import os
tailoutputfile = os.popen('tail -f syslog')
while 1:
    line = tailoutputfile.readline()
    if len(line)==0:   # change the termination condition 
        break
    process_line(line)

and it works great. But not sure how to use this with
ssh command to connect to remote machine.

Any tips?



More information about the Python-list mailing list