Question

I am a newby to this but I am tasked at writing a tcl script. The script is to print a message on the command line "Warning, system error detected" when a syslog system_error is found.

Now I am completely new to tcl and all I know is that an event_register_syslog needs to be used. Other than that I am completely in the dark and do not know where to go or start.

There are no GUIs needed just the CLI.

Any help and support would be much appreciated.

Était-ce utile?

La solution

I'd hate to down-vote your question, but really, you should include some example of the syslog and show a bit more effort (ie. code stubs) or research that you've done.. however, I understand what's it's like to have no idea where to start.. so here is a bit of code that should get you started:

#set result variable equal to contents of syslog  
set result [exec puts syslog]

#parse syslog line by line searching for error
foreach line [string trim [split $result "\n"]] {
    #regex the error string
    if {[regexp {Whatever Error Massage may look like!}]} {
        puts "Warning, system error detected"
    }

Here are some useful regex links for tcl:

  1. http://www.regular-expressions.info/tcl.html
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top