0

I Wrote some Tkinter Python code to tail log-dumps. But I want to tail the log files in a remote server, where I have permission to login.

import sys,os
import time
from Tkinter import *
from ScrolledText import ScrolledText

class LogViewer(Frame):
    def __init__(self, parent, filename):
        Frame.__init__(self,parent)
        self.filename = filename
        self.file = open(filename, 'r')
        self.text = ScrolledText(parent)
        self.text.pack(fill=BOTH)
        data = self.file.read()
        self.size = len(data)
        self.text.insert(END, data)
        self.after(100, self.poll)

def poll(self):
    if os.path.getsize(self.filename) > self.size:
        data = self.file.read()
        self.size = self.size + len(data)
        self.text.insert(END, data)
        self.after(100,self.poll)

if __name__ == "__main__":
    root = Tk()
viewer = LogViewer(root, sys.argv[1])
viewer.mainloop() 

Can someone give me some pointers on how to integrate this to tail log-files on remote hosts. The urge is to execute a script on a remote server and track the progress via tailing the log-file.

Regards.

1 Answer 1

0

Is your local machine also running Linux? If so, I think the easiest way to do this would be to mount the remote machine as a network filesystem, using sshfs or ftpfs. Then you wouldn't have to change anything in your Python script, just feed it the mounted path and it would work.

2
  • Naa, Now I intend to run it in windows!
    – Vivek
    Feb 18, 2013 at 12:47
  • Sorry for getting back to this so late. So what kind of access do you have from your local Windows machine to the remote Linux server? It would be easy if the log files were shared via Samba, for instance. And if you have an SSH access through PuTTy or the like, then I guess I don't really understand why you need to tail the log files through a local Python application. Is it because you want to have an infinite scrollback buffer? Feb 19, 2013 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.