Snort alert tail...

Michael Davis michael at damaru.com
Sun Jun 16 10:34:42 EDT 2002


Jan-Eric wrote:

> HEllo !
> I'm trying to write a dynamic firewall script in python that scans the
> Snort alert file like 'tail -f' and takes action based on the infomation
> it gets from that file. But I can't get the 'tail' function to work.It
> reads the file, but any new information that Snort is writing to the file
> doesn't show up to the script.
> 
> ex.
> file = open('/var/log/snort', 'r')
> while 1:
>         file = file.read()
>         print file
> ....
> 
> Any suggestions???
> Jan-Eric / Finland

Hi,

Why don't you try opening a pipe to the output of 'tail -f' ? I haven't 
tried this, but you could probably do:

import os

file = os.popen( 'tail -f /var/log/snort' )

etc.

-- 
Michael Davis
Damaru
Custom Programming - Web Development - Database Design
http://www.damaru.com
416-540-1284



More information about the Python-list mailing list