A sample shell script
#!/bin/sh
viperooe_home=`dirname $0`
source $viperooe_home/env-viperooe.sh
instancename=$1
cd $viperooe_home/persistence/$1
currentDate=`date '+%Y%m%d'`
echo $currentDate
currentTime=`date '+%H%M%S'`
echo $currentTime
logName=orderStoreRatio-$currentDate-$currentTime.log
echo here is it! $viperooe_home/$logName
echo "orderstore usage info:" >> $viperooe_home/$logName
typeset -i used=`od -c orderstore |grep 'c i b c' | head -1 | awk '{print $1}'`
echo "Currently used: $used" >> $viperooe_home/$logName
typeset -i total=`od -c orderstore |tail -1`
echo "Totally we have: $total" >> $viperooe_home/$logName
typeset -i ratio=used*100/total
echo "orderstore Usage ratio: $ratio%" >> $viperooe_home/$logName
how to define a string
Simply follow this way:
currentDate=`date '+%Y%m%d'`
echo $currentDate
Don’t use set like this:
set currentDate=`date '+%Y%m%d'`
echo $currentDate
Conclusion: It’s quite strange that, use keyword set, it doesn’t work. But if you call the above 2 lines directly in command line($) it works fine.
How to define a integer
typeset -i used=`od -c orderstore |grep 'c i b c' | head -1 | awk '{print $1}'`