LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   parse /etc/syslog.conf file (https://www.linuxquestions.org/questions/programming-9/parse-etc-syslog-conf-file-882587/)

catalint 05-25-2011 04:20 AM

parse /etc/syslog.conf file
 
Hello there,

Guys I've got an issue and I need a hint...I have to create a sh script which parse /etc/syslog.conf file (under solaris) and need to get all path accordingly to all logs configured in there.

If anybody knows more about this please let me know. Thanks .

catkin 05-25-2011 06:25 AM

What have you tried so far? What are the contents of /etc/syslog.conf?

tronayne 05-25-2011 06:34 AM

About trying awk? Pretty easy to parse with AWK -- I'd check to see if awk is linked to oawk or nawk and use nawk if it's linked to oawk but other than that it ought to be straightforward.

Hope this helps some.

catalint 05-26-2011 02:02 AM

Hello,

The content of the file is bellow.Right now I'm trying to find what to use..awk or sed, i don't have so much experience with these tools and I need some ideas. I need to get from this config file ALL the paths to log files that are configured , for example /var/adm/messages



#ident "@(#)syslog.conf 1.5 98/12/14 SMI" /* SunOS 5.0 */
#
# Copyright (c) 1991-1998 by Sun Microsystems, Inc.
# All rights reserved.
#
# syslog configuration file.
#
# This file is processed by m4 so be careful to quote (`') names
# that match m4 reserved words. Also, within ifdef's, arguments
# containing commas must be quoted.
#
*.err;kern.notice;auth.notice /dev/sysmsg
*.err;kern.debug;daemon.notice;mail.crit /var/adm/messages

*.alert;kern.err;daemon.err operator
*.alert root

*.emerg *

# if a non-loghost machine chooses to have authentication messages
# sent to the loghost machine, un-comment out the following line:
#auth.notice ifdef(`LOGHOST', /var/log/authlog, @loghost)

mail.debug ifdef(`LOGHOST', /var/log/syslog, @loghost)

#
# non-loghost machines will use the following lines to cause "user"
# log messages to be logged locally.
#
ifdef(`LOGHOST', ,
user.err /dev/sysmsg
user.err /var/adm/messages
user.alert `root, operator'
user.emerg *
)

catkin 05-26-2011 06:38 AM

Quote:

Originally Posted by catalint (Post 4367347)
Right now I'm trying to find what to use..awk or sed

If you know C then awk will come more naturally than sed after you have familiarised with the pattern-action concept and awk is more powerful than sed, being a full programming language as opposed to a very competent stream editor.


All times are GMT -5. The time now is 01:35 PM.