expr non-numeric argument shell script

Posted by Kimi on Stack Overflow See other posts from Stack Overflow or by Kimi
Published on 2010-05-03T11:53:47Z Indexed on 2010/05/03 11:58 UTC
Read the original article Hit count: 425

Filed under:
|
|
|

The below check is not working : expr non-numeric argument shell script. Always it is going to else. Please tell me what is the mistake.

Earlier I was no using while so the same thing was woring fine now suddenly when I did put it in the while loop it is no working.

        echo "`${BOLD}`    ***** Checking Memory Utilization User*****`${UNBOLD}`"
        echo "==================================================="

        IFS='|'
        cat configMachineDetails.txt | grep -v "^#" | while read MachineType UserName MachineName
        do
                export MEMORY_USAGE1=`ssh -f -T ${UserName}@${MachineName} prstat -t -s rss 1 2 | tr '%' ' '| awk '$5>5.0'`
                export LEN=`echo "$MEMORY_USAGE1"|wc -l`
                export CNPROC=`echo "$MEMORY_USAGE1"|grep "NPROC"|wc -l`
                export CTotal=`echo "$MEMORY_USAGE1"|grep "Total"|wc -l`

                **if [ $LEN = `expr $CNPROC + $CTotal` ]
                        then
                                echo "`${BOLD}`**************All usages are normal !!!!!! *************`${UNBOLD}`"
                        else
                                echo "`${BOLD}`**** Memory(%) is more than 5% in MachineType $MachineType  UserName $UserName
 MachineName  $MachineName   *******`${UNBOLD}`"
                                echo "===================================================="
                                echo "$MEMORY_USAGE1"
                fi**

        done

© Stack Overflow or respective owner

Related posts about scripting

Related posts about ksh