Page 1 of 1

CPU/Drive Temp Error - Unary Operator

Posted: September 10th, 2011, 8:22 pm
by djs72
Ian, Great site, many thanks. Complete newbie but following everything quite well - thanks. I've followed your scripting instructions with ease but when I submitted new jobs in Execute new cron job, I thought I'd run them both to see if they worked correctly and got the following outputs :

>
Output from command /home/djsherlock72/MyScripts/DriveTempShutdown.sh 35 45 >/dev/null ..

/dev/sda: Permission denied
/home/djsherlock72/MyScripts/DriveTempShutdown.sh: line 59: [: =: unary operator expected
/home/djsherlock72/MyScripts/DriveTempShutdown.sh: line 68: [: -ge: unary operator expected
/home/djsherlock72/MyScripts/DriveTempShutdown.sh: line 79: [: -ge: unary operator expected
>

and

>
Output from command /home/djsherlock72/MyScripts/CPUTempShutdown.sh 35 45 >/dev/null ..

/home/djsherlock72/MyScripts/CPUTempShutdown.sh: line 49: [: -ge: unary operator expected
/home/djsherlock72/MyScripts/CPUTempShutdown.sh: line 59: [: -ge: unary operator expected
/home/djsherlock72/MyScripts/CPUTempShutdown.sh: line 49: [: -ge: unary operator expected
/home/djsherlock72/MyScripts/CPUTempShutdown.sh: line 59: [: -ge: unary operator expected
>

Is this not running correctly or should I just ignore it?

Re: CPU/Drive Temp Error - Unary Operator

Posted: September 10th, 2011, 9:04 pm
by Ian
Hello there and welcome to the forum. It's nice to hear you've taken the plunge. I hope you don't regret it :thumbup:

OK, both these scripts are written for my particular motherboard and drives so you'll need to tweak them to suit your setup. It's not tricky by any means and I'll help you.

The first problem with your first script (DriveTempShutdown.sh) is you need to run the cron job as root. I'm guessing you've configured the cron job to run as your username?

Both scripts are looking for output in specific columns and the output you're seeing is different to mine so you need to edit the scripts. So let's tackle the CPUTempShutdown.sh script first:

Please type the following command and post the output in your next post:

Code: Select all

sensors


For the DriveTempShutdown.sh script please paste the following two lines of code after the str2=$($str1 | grep Temperature_Celsius | awk '{print $10}') command which is line 66 in the script. As above, please post the output in your next post.

Code: Select all

echo $(str1)
echo $(str2)


Ian.

Re: CPU/Drive Temp Error - Unary Operator

Posted: September 10th, 2011, 9:27 pm
by djs72
sensors output :

acpitz-virtual-0
Adapter: Virtual device
temp1: +40.0°C (crit = +75.0°C)

k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp: +32.0°C

Output from drivetemp script now with the new two lines in (and running as root):

/home/djsherlock72/MyScripts/DriveTempShutdown.sh: line 67: str1: command not found
/home/djsherlock72/MyScripts/DriveTempShutdown.sh: line 68: str2: command not found

Re: CPU/Drive Temp Error - Unary Operator

Posted: September 10th, 2011, 10:44 pm
by Ian
Hi,

Thanks for this. OK, for the CPUTempShutdown.sh script you want to change line 46 from str=$(sensors | grep "Core $i:") to str=$(sensors | grep "Core0"). Then run the script again and let me know what it says

For the DriveTempShutdown.sh script I made a typo, sorry. Please replace the two commands I gave earlier with these two (ie. no brackets):

Code: Select all

echo $str1
echo $str2


And then run the script again please.

Thanks.

Ian.