smartctl -a $drive
where $drive is your hard drive, /dev/sda, /dev/hda or so. Then look for the bottom of the output:
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 136 -
If you have such line, then there is problem with this script not interpreting this correctly. If you don't, chances are that you haven't run SMART test on this hard drive previously. If this is the case, run
smartctl --test short $drive
And wait for about 3 minutes. You can see the progress of this test by running smartctl -a $drive, along the lines of
Self-test execution status: ( 241) Self-test routine in progress...
10% of test remaining.
After that, smarttest should be able to fill "$HOURS" variable inside the script.
Some bits of details:
The line looks like
if [ $HOURS -ge 26280 ]; then
With HOURS value missing it transforms into "if [ -ge 26280 ]; then ..." while -ge is not an unary operator, i.e. it accepts 2 arguments, while it is supplied only one.