I'm still confused by this thread. With the script you showed us, it should work just fine (with or without double quotes around the expansions of the variables your [[ expression ]] statements) if t is run by a 1993 or later version of the Korn shell (including version 93u+, which is what you say you are using).
The diagnostic messages you showed us are something that I would expect to see if you executed a script similar to what you showed us using bash as your shell instead of ksh. And, I say a script similar to (but not the script you showed us) because the diagnostics point to problems in the [[...]] statements on lines 15 and 19 in your script; but the script you showed us has those statements on lines 12 and 15 (NOT 15 and 19).
But, running successfully and producing the results you want are two different issues. From your problem statement, I thought you wanted to produce a warning or critical message if field 10 in the uptime output is 3% or 5%, respectively, higher than the lower or the field 11 or field 12 values. (I.e., the current 1 minute value is greater than the 5 and 15 minute values.) But, the code you showed us (if run by a 1993 or later ksh), if the field 11 or 12 value is less than 103% or 105% of the field 10 value. So, for example, if fields 10, 11, and 12 all contained the value 1.00 (showing absolutely no increase in load in the last 15 minutes; your script would report a critical condition because 105% of the field 10 value (1.05) is greater than the field 11 and 12 values (1.00). Is this really what you want?
The following script should do what you want on your Linux system. If you also have a 1993 or later version of ksh on your Solaris system (which might only be true if you're running a Solaris 11.0 or later system), the following would do what I think you described in your requirements just using shell built-ins. I must say, however, that I don't understand the need to include the current load value (as contained in $str1) in each of your three possible output messages) twice.
If you need something that will work on a system running a Solaris 10 or earlier release without a ksh93, and you find that the above script does what you want on your Linux system, we'll need to look for an alternative solution.
This User Gave Thanks to Don Cragun For This Post:
is it not possible to simply di aritmetic without using bc or awk
i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant... (6 Replies)
I am begining to learn bourne shell and as a practice I have written a script which when given the purchase price and percentage of discount calculates the savings.
I somehow cannot figure out why my script fails to do arthimatic calculation on real numbers.
Could anyone look at the script... (5 Replies)
hi,
i have a bash script that i want to receive a a string from another bash file. But because the string has a dot in the middle it gives me an error. The error is in this line:
let valor=$1
and the value passed is rules.txt
the error is:
let: valor=rules.txt: syntax error: invalid... (2 Replies)
i'm trying to make a script to simply add numbers together
for example i have a file script file called add
add 1 2 3 4 5
15
however i want the user to put at least 3 numbers so i did this
if
then
echo "please enter more than two numbers"
exit 1
fi
but it's telling me i have... (3 Replies)
hi there again,
i need to do a simple division with my data with a number of rows. i think i wanted to have a simple output like this one:
col1 col2 col3
val1 val2 val1/val2
valn valm valn/valm
any suggestion is very much appreciated. thanks much. (2 Replies)
I am writing a script in zsh shell, it fetchs a number from a file using the awk command, store it as a variable, which in my case is a small number 0.62000. I want to change this number by multiplying it by 1000 to become 620.0 using the command in the script
var2=$((var1*1000))
trouble is... (2 Replies)
Hi,
I am trying to do an addition to a value stored in a variable...
var1=`grep -n "match" sample.txt|cut -d : -f1`
var2=`echo $var1|cut -d " " -f1` (Here i want add +1 to the output value) (4 Replies)
Hi experts,
I'm facing trouble with the below bash script, any help is appreciated
#!/usr/bin/bash
..
if (( "${date1}" > "${l_date1}" ))
then
echo "success"
else
echo "nothing"
fi
the variable date1 contains 08/06/2013 and l_date1 contains 10/08/2013
this small script to... (6 Replies)
Hello.
LEAP_VERSION="4.2"
export ARRAY_MAIN_REPO_LEAP=('zypper_local' 'openSUSE-Leap-'"$LEAP_VERSION"'-Non-Oss' 'openSUSE-Leap-'"$LEAP_VERSION"'-Oss' 'openSUSE-Leap-'"$LEAP_VERSION"'-Update' 'openSUSE-Leap-'"$LEAP_VERSION"'-Update-Non-Oss')Seems that the - is interpreted as a numeric... (2 Replies)
Hi guys...
I am working on limited basic set of maths routines for ksh93 that can be sourced as . ./ksh_math.sh and I am gobsmacked by its capabilities.
Although some big guns may already know this, I didn't, and ksh93 is easily able to do floating point numbers to floating point powers and... (16 Replies)