Image

Imagelinux_geek wrote in Imagelinux

Help with bash script please

My script works, but the temperature variable doesnt update with the printf command.
Any ideas? I know its working, because its keeping the temp down.


SPEEDONE=1
SPEEDTWO=1
CRITICAL=1
COUNTER=0

ld=`cat /proc/i8k | awk '{print $4}'`
echo "George's Inspiron 5100 Temperature Regulation Script"
echo "Version 3.0"

while [ $COUNTER -lt 10 ]; do

ld=`cat /proc/i8k | awk '{print $4}'`

#keep fan on 1
if [ "$ld" -le "50" ];
then i8kfan 0 1 1>/dev/null 2>&1;

#Only notify once
if [ $SPEEDONE = "1" ]; then
printf "Current Temperature:$ld Current Status: Fan speed 1 \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
fi

let 'SPEEDONE=0';
let 'SPEEDTWO=1';
let 'CRITICAL=1';
sleep 10

ld=`cat /proc/i8k | awk '{print $4}'`

fi

#turn down fan
if [ "$ld" -gt "50" -a "$ld" -le "55" ] ;
then i8kfan 0 1 1>/dev/null 2>&1;

#Only notify once
SPEEDONE=1
SPEEDTWO=1
CRITICAL=1
COUNTER=0

ld=`cat /proc/i8k | awk '{print $4}'`
echo "George's Inspiron 5100 Temperature Regulation Script"
echo "Version 3.0"

while [ $COUNTER -lt 10 ]; do

ld=`cat /proc/i8k | awk '{print $4}'`

#keep fan on 1
if [ "$ld" -le "50" ];
then i8kfan 0 1 1>/dev/null 2>&1;

#Only notify once
if [ $SPEEDONE = "1" ]; then
printf "Current Temperature:$ld Current Status: Fan speed 1 \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
fi

let 'SPEEDONE=0';
let 'SPEEDTWO=1';
let 'CRITICAL=1';
sleep 10

ld=`cat /proc/i8k | awk '{print $4}'`

fi

#turn down fan
if [ "$ld" -gt "50" -a "$ld" -le "55" ] ;
then i8kfan 0 1 1>/dev/null 2>&1;

#Only notify once
if [ $SPEEDONE = "1" ]; then
printf "Current Temperature: $ld Current Status: Fan speed 1 \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b
\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
fi

let 'SPEEDTWO=1';
let 'SPEEDONE=0';
let 'CRITICAL=1';
sleep 10

ld=`cat /proc/i8k | awk '{print $4}'`

fi

if [ "$ld" -ge "56" ];
then i8kfan 0 2 1>/dev/null 2>&1;

#Only notify once
if [ $SPEEDTWO = "1" ]; then
printf "Current Temperature: $ld Current Status: Fan Speed 2 \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
fi

#If critical
if [ $CRITICAL = "1" ]; then
printf "Current Temperature: $ld Current Status: Temp Critical\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b
\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
fi

let 'SPEEDTWO=0';
let 'SPEEDONE=1';
let 'CRITICAL=0';
sleep 2

ld=`cat /proc/i8k | awk '{print $4}'`

fi



If you guys have any better ideas for a cooling "algorithm" (this one works better than SuSE 9.2 power management) then please let me know.