Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
icon5.gif   Simple math within an elog form, posted by Steve Jones on Tue Apr 4 06:18:18 2006 
    icon2.gif   Re: Simple math within an elog form, posted by Stefan Ritt on Tue Apr 4 08:15:29 2006 
       icon2.gif   Re: Simple math within an elog form, posted by Steve Jones on Wed Apr 5 00:00:14 2006 
          icon2.gif   Re: Simple math within an elog form, posted by Stefan Ritt on Wed Apr 5 10:07:59 2006 
             icon2.gif   Re: Simple math within an elog form, posted by Steve Jones on Wed Apr 5 13:50:14 2006 
                icon14.gif   Re: Simple math within an elog form, posted by Steve Jones on Wed Apr 5 18:56:48 2006 
Message ID: 1794     Entry time: Wed Apr 5 13:50:14 2006     In reply to: 1793     Reply to this: 1795
Icon: Reply  Author: Steve Jones  Author Email: steve.jones@freescale.com 
Category: Request  OS:   ELOG Version: 2.6.1 
Subject: Re: Simple math within an elog form 

Stefan Ritt wrote:

Steve Jones wrote:
Subst TotalRisk = $shell(echo $Risk1 + $Risk2 + $Risk3 > /tmp/elog_out)

What comes out with my simple echo or gawk line is "+ + " so it looks like the attributes are not getting passed into the $shell code?


The reason is that the substitutions get evaluated from left to right, so first the shell is called with $Risk1, and because the shell by itself does a subsitution and $Risk1 is not defined on the unix system, the shell returns an empty string, leading to "+ +" as the result.

I changed that in the current SVN version, so we have first the attribute substitions, then then shell substitution. The "echo $Risk1..." will of course not work, since it gets substituted by elog as "echo 12 + 23 + 45" (or whatever the numbers are), and the "echo" will just return these numbers without adding them. To make the shell to add things, you would need to define the risks as environment variables for the shell, so I guess the "gawk" method will work better for you. I tried it and it worked fine for me.


Sorry, I waSn't clear about just why I was using "echo". Since elog removes the /tmp/elog_shell temporary file I couldn't "see" what was actually being passed to the shell - gawk was giving me an error and I was flying blind. So I used echo to create my own temporary file.

Yes, gawk should now work -- I'l download and compile the latest and provide feedback.

Thanks!
ELOG V3.1.5-fe60aaf