Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 770609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:31:33+00:00 2026-05-14T18:31:33+00:00

The below check is not working: if [ $LEN = `expr $CNPROC + $CTotal`

  • 0

The below check is not working:

if [ $LEN = `expr $CNPROC + $CTotal` ])

and returns expr non-numeric argument shell script.

Always it is going to else. Please tell me what is the mistake.

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

#!/usr/bin/ksh 
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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:31:34+00:00Added an answer on May 14, 2026 at 6:31 pm

    Put the following statements before your if statement:

    echo "[$MEMORY_USAGE1]"
    echo "[$LEN]"
    echo "[$CNPROC]"
    echo "[$CTotal]"
    

    and see what comes out. That error is alnmost invariably caused, surprisingly enough :-), by passing non-numeric data to expr and the echo statements should tell you exactly what the problem is.

    For example:

    pax> expr 1 + x
    expr: non-numeric argument
    

    Based on your comment that your output is:

    [ NPROC USERNAME SWAP RSS MEMORY TIME CPU
    Total: 143 processes, 2449 lwps, load averages: 1.76, 2.56, 2.94 
    NPROC USERNAME SWAP RSS MEMORY TIME CPU
    Total: 148 processes, 2443 lwps, load averages: 1.82, 2.57, 2.95]
    [ 4]
    [ 2]
    [ 2]
    

    it’s possible that the spaces preceding your numeric values are causing your problems. Try replacing all your occurrences of:

    |wc -l
    

    with:

    |wc -l|sed 's/ //g'
    

    to get rid of spaces in the wc output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer DDay.ical includes more than what you're looking for (it's a… May 16, 2026 at 4:11 pm
  • Editorial Team
    Editorial Team added an answer & is the string concat operator, AND and && are… May 16, 2026 at 4:11 pm
  • Editorial Team
    Editorial Team added an answer The reset is this.reset(); so that is in the scope… May 16, 2026 at 4:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I use below code for check that searchText exist in name or not but
My jQuery is not working as expected: I am trying to loop through each
I want to select all checkbox when i click the top check, below is
I'd like to check if a certain variable is set inside my template...if it
Please see the form HTML code below <form method=post action=register> <div class=email> Email <input
Iam using highslide js for my image blow up section and its working fine.
I am using a CompareValidator to check user input on one of my forms
I am just trying to check whether compiler allows type name as variable name.
I'm trying to create an admin user as part of my tests.py to check
This question is about verifying the assembly to check whether it is tampered for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.