one of its statement is :
Code: Select all
calc=/tmp/memcalc
......
# Total memory available
total=`free -m | head -2 |tail -1 |gawk '{print $2}'`
# Total memory used
used=`free -m | head -2 |tail -1 |gawk '{print $3}'`
# Calc total minus used
free=`free -m | head -2 |tail -1 |gawk '{print $4+$7}'`
# normal values
#echo "$total"MB total
#echo "$used"MB used
#echo "$free"MB free
# make it into % percent free = ((free mem / total mem) * 100)
echo "5" > $calc # decimal accuracy
echo "k" >> $calc # commit
echo "100" >> $calc # multiply
echo "$free" >> $calc # division integer
echo "$total" >> $calc # division integer
echo "/" >> $calc # division sign
echo "*" >> $calc # multiplication sign
echo "p" >> $calc # print
percent=`/usr/bin/dc $calc|/bin/sed 's/^\./0./'|/usr/bin/tr "." " "|/usr/bin/gawk {'print $1'}`on my arm,i used 'dc -V',it shows:
dc -V
BusyBox v1.13.2 (2010-06-21 12:46:04 IST) multi-call binary
Usage: dc expression...
Tiny RPN calculator. Operations:
+, add, -, sub, *, mul, /, div, %, mod, **, exp, and, or, not, eor,
p - print top of the stack (without altering the stack),
f - print entire stack, o - pop the value and set output radix
(value must be 10 or 16).
Examples: 'dc 2 2 add' -> 4, 'dc 8 8 * 2 2 + /' -> 16.
but when i use it on pc,it shows:
dc (GNU bc 1.06.95) 1.3.95
Copyright 1994, 1997, 1998, 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
so what i want ask is :how should i modify the script to solve this problem.
i hope i had expressed clearly,if you know something ,please help me ,thank you!