I am using config parser to parse a config file I need to tail each file in the files section in a separate terminal I am using python on mac
the code I wrote gets me all the things in the files section I need only the paths and need to tail each one of them in a separate child process
import ConfigParser
import os
def ConfigSectionMap(section):
dict1 = {}
options = Config.options(section)
for option in options:
try:
dict1[option] = Config.get(section, option)
if dict1[option] == -1:
DebugPrint("skip: %s" % option)
except:
print("exception on %s!" % option)
dict1[option] = None
return dict1
Config = ConfigParser.ConfigParser()
Config.read("/etc/harvest.conf")
print Config.sections()
print ConfigSectionMap("files")
sample config file is
[section1] host_prefix = true
timestamp_prefix = true
[section2] host = localhost
port = 1463
pids = /var/run/harvester
[files] apache.access = /var/log/apache2/access.log
apache.errors = /var/log/apache2/errors.log
mail = /var/log/mail.log
mysql.log = /var/log/mysql.log
mysql.err = /var/log/mysql.err
syslog.err = /var/log/syslog.err
Since
tailis accepting multiple files, you can rely on it: