Originally Posted by
Philliesfan251
Check the code you quoted
Whoops. Total reading comprehension fail on my part.
Try running the following command (I had an extra parenthesis at the end):
Code:
/usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}'
I went ahead and ran a similar command here. Note that I am traveling for work and don't have access to my server, but I am in front of a linux machine. I literally ran the following command (I don't have hddtemp installed on this machine so I had to fake the output of hddtemp. That's why I have that echo command in there. But this should be mostly identical to what your hddtemp is putting out.):
Code:
echo '/dev/sda: WDC WD2500YS-01SHB1: 25°C' | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}'
and got back this:
Note the degree symbol plus the letter 'C'. That is what is messing up the next line which expects just an integer.
If I modify your command just the tiniest bit (replace the funky characters with a degree symbol) it gets closer:
Code:
echo '/dev/sda: WDC WD2500YS-01SHB1: 25°C' | sed 's/\(.*\)://g' | awk -F '°' '{ print $1}'
this gets me:
This is just the temperature, but note that it still leaves me with some leading spaces. I don't know if that is going to be an issue or not, but my original line in my script does not have any leading spaces.
I modified the line to remove any leading spaces (this might be the overkill way to do it, but it was the fastest way I could think of):
Code:
echo '/dev/sda: WDC WD2500YS-01SHB1: 25°C' | sed 's/\(.*\)://g' | sed 's/^[ \t]*//' | awk -F '°' '{ print $1}'
This returns just an integer.
So... after all of that, try putting the following line into your script:
Code:
HDTEMP=$($HDT $disk | sed 's/\(.*\)://g' | sed 's/^[ \t]*//' | awk -F '°' '{ print $1}')
Double check that line yourself to make sure it makes sense. We have already established that my reading comprehension is a bit off
That should get your script functioning correctly.
I hope.
Bookmarks