[Tutor] Linux tail -f multiple log files

Bill Campbell bill at celestial.net
Wed Jan 7 01:46:41 CET 2009


On Tue, Jan 06, 2009, David wrote:
>>
>> 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
>>
> oops should be;
> 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, targ, sfile])

Looking at how swatch does this I think the command you want to use is:

cmd = 'sudo tail --follow=name --lines=1 %s' % ' '.join(args)
tail = os.popen(cmd)
# process output
...

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

It does not require a majority to prevail, but rather an irate, tireless
minority keen to set brush fires in people's minds. -- Samuel Adams


More information about the Tutor mailing list