Please help to debug a small shell script (maybe AWK problem)?

Hi Buddies,
The following is shell scripts which was borrowed from linux box for load average check. it runs good.
(this structure is simple, when load average is too high, it will send alert to user)

#!/usr/bin/ksh

# Set threshold for 1, 5 and 15 minture load avarage
# configured for 12-processors system

max_1=48
max_5=36
max_15=24

# Set the string which appears before the load average in the uptime command
load_text='load average: '

#Email list
mail_to='abc@abc.com'

alert=n

up=`uptime`

# Parse out the current load average from the uptime command

load_1=`echo $up | /usr/xpg4/bin/awk -F "$load_text" '{ print $2 }' | cut -d, -f1 | cut -d. -f1`

load_5=`echo $up | /usr/xpg4/bin/awk -F "$load_text" '{ print $2 }' | cut -d, -f2 | cut -d. -f1`

load_15=`echo $up | /usr/xpg4/bin/awk -F "$load_text" '{ print $2 }' | cut -d, -f3 | cut -d. -f1`

# Set alert=y if any of the average are above their thresholds
if [ $load_1 -ge $max_1 ]
then
alert=y
elif [ $load_5 -ge $max_5 ]
then
alert=y
elif [ $load_15 -ge $max_15 ]
then
alert=y
fi

# Send mail if the alert threshold was reached
if [ ! $alert = n ]
then
mail -s "High load on procede02" $mail_to < `uptime`
fi

---
Now we use it in solaris 9, get some errors like

$./monitor_load_average.sh
./monitor_load_average.sh[43]: 9:32am up 3 day(s), 6:30, 9 users, load average: 0.32, 0.58, 0.55: cannot open

Can any expert give me a hand to debug it? (why have [43]..? why can not open? ..I think this is a syntax problem in AWK..)

Thank you very much in advance

Jerry

Jerry-

Just from an initial peek at your script, I would put double quotes around ALL variables in the if statement and the elif statements.

Try that and see what happens.

HTH

Tony

While I agree with the double quotes as a good general practice, it won't solve your problem:

mail -s "High load on procede02" $mail_to < `uptime`

You can't do that. You are trying to use the output of uptime as a file to be opened. You don't have a file by that name, so you get the "can not open".

And [43] means the shell was at line 43 on the script when it decided it had a problem. Sometimes the error is earlier in the file, but never later.

My first thought is that the < `uptime` in your mail command is giving you a problem. I think mail is expecting a file and not the output of a command.
Perhaps store uptime to a file, and then use that filename in place of the `uptime`.

Hi, all friends,
You all are right.
it is fixed by creating file instead of command.
thank you all very much
Jerry