Monday, June 05, 2006

correction to script

Corrected version of script reads

MINUTES=`echo "scale=1; ($MINUTES/15)" | bc -l`
MINUTES=$(printf "%2.0f" $MINUTES)
MINUTES=`echo "scale=0; ($MINUTES*15)" | bc -l`
MINUTES=$(printf "%02d" $MINUTES)

if [ "$MINUTES" = "60" ]
then
HOURS=`echo "scale=0; ($HOURS+1)" | bc -l`
HOURS=$(printf "%02d" $HOURS)
MINUTES=00
fi

if [ "$HOURS" = "24" ]
then
HOURS=00
fi
This has the printf part only if bc is called. Else, sometimes printf gives errors like
 printf: 08: invalid number

No comments:

Post a Comment