Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
icon4.gif   Interesting behavior with $shell, posted by Steve Jones on Fri Oct 27 19:11:32 2006 
    icon2.gif   Re: Interesting behavior with $shell, posted by Steve Jones on Sun Oct 29 16:04:05 2006 
Message ID: 2023     Entry time: Fri Oct 27 19:11:32 2006     Reply to this: 2024
Icon: Warning  Author: Steve Jones  Author Email: steve.jones@freescale.com 
Category: Bug report  OS: All  ELOG Version: 2.6.2-1723 
Subject: Interesting behavior with $shell 
eLog does not do math so I am trying to leverage the $SHELL function to perform the math. I am using GAWK to perform the math -- I started trying to use CONDITIONAL ATTRIBUTES to assign numeric values to attributes but with loading up the ATTRIBUTES with all of the options brings elog to its knees in terms of performance -- the parsing of attributes is simply too string intensive.

So, I embedded the numeric score in the OPTIONS of the ATTRIBUTE and leveraged the text processing prowess of GAWK:
Options WhoIsEffected =   1:...Single User, 5:...Project, 10:...Department, 50:...Site
Options ServiceOutage =   1:...0-1 Minutes, 2:...10 Minutes, 10:...20 Minutes, 30:...30 Minutes, 100:...gt60 

Then pass the following command to GAWK:
Preset TotalScore = $shell(gawk 'BEGIN{split(\"$WhoIsEffected:$ServiceOutage\",scores,\":\");print scores[1]+scores[3]}' )

The interesting result is this works - the proper summation is returned but apparently elog parsing also returns everything after the first ')' as something that also needs to be returned. So the resulting contents of TotalScore is
2;print scores[1]+scores[3]}' ) 
assuming one chose the first option of both attributes (the output pasted here are real results).

Before getting to this point I tried using the GAWK internal variable of $0 - but this did not work because apparently $0 in elog is defined as the OS shell!

Stefan, is it possible for you to try creating a logbook on the elog demo site that shows people how to perform math and in the process discover what the $SHELL function is doing?
ELOG V3.1.5-3fb85fa6