[mrtg] Re: Need Bash help

Jay Hennigan jay at west.net
Thu Mar 21 03:35:16 MET 2002


On Wed, 20 Mar 2002, Max Kipness II wrote:

> Hello All,
>
> I've created a script that monitors the response time (latency) of DNS
> servers and creates an MRTG graph out of it. I've got  most of it ironed
> out, but am having a problem with multiplication in the script. The
> bottom line is that I can't figure out how to multiply a decimal value.
> I have posted below only a sample of the operation I'm trying to do
> rather than the whole script. Here it is:
>
> #!/bin/bash
> ARG2=.2
> echo $(( 100 * $ARG2 ))
>
> This reports back an error. If you simply change it to read ARG2=2
> (without the decimal), it works fine.
>
> Is there any way around this?

Bash arithmetic expressions are long integers.  It won't work with
decimal values.  For your specific example,

#!/bin/bash
ARG2=5
echo $(( 100 / $ARG2 ))

will work, but return only the integer portion of the result.  :-)

-- 
Jay Hennigan - CCIE #7880 - Network Administration - jay at west.net
NetLojix Communications, Inc.  -  http://www.netlojix.com/
WestNet:  Connecting you to the planet.  805 884-6323


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list