[Tutor] Linux tail -f multiple log files

David david at abbottdavid.com
Wed Jan 7 01:34:28 CET 2009


Hi,
This works fine if I don't use the -f option;
#!/usr/bin/python
from subprocess import call
from termcolor import colored

def slog():
     sudo = "sudo"
     tail = "tail"
     sfile = "/var/log/messages"
     print colored("<syslog>", "blue")
     call([sudo, tail, sfile])


def alog():
     sudo = "sudo"
     tail = "tail"
     afile = "/var/log/apache2/access_log"
     print colored("<access_log>", "green")
     call([sudo, tail, afile])

def elog():
     sudo = "sudo"
     tail = "tail"
     afile = "/var/log/apache2/error_log"
     print colored("<error_log>", "red")
     call([sudo, tail, afile])

def main():
     slog()
     alog()
     elog()

if __name__ == "__main__":
     main()

Now if I do this to all the functions;
def slog():
     sudo = "sudo"
     tail = "tail"
     targ = "-f" # output appended data as the file grows
     sfile = "/var/log/messages"
     print colored("<syslog>", "blue")
     call([sudo, tail, sfile])

Only the first function will print to the screen.

thanks in advance,
-david

-- 
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu



More information about the Tutor mailing list