- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- I have problem in scripting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 01:59 AM
09-14-2005 01:59 AM
How can i take and compare numeric value in "if" condition i have following script but that is not comparing numeric value and is not working according to condition
1 #!/usr/bin/sh
2 NUM=`df -k /stand |awk '/allocation used/'`
3 if [ $NUM -gt 70 ]
4 then
5 echo "$NUM"
6 fi
7 NUM=`df -k / |awk '/allocation used/'`
8 if [ $NUM -gt 70 ]
9 then
10 echo "$NUM"
11 fi
12 NUM=`df -k /tmp |awk '/allocation used/'`
13 if [ $NUM > 70 ]
14 then
15 echo "$NUM"
16 fi
17 NUM=`df -k /var |awk '/allocation used/'`
18 if [ $NUM > 70 ]
19 then
20 echo "$NUM"
21 fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:02 AM
09-14-2005 02:02 AM
Solution2 NUM=`df -k /stand |awk '/allocation used/{print $1}'`
3 if [ $NUM -gt 70 ]
4 then
5 echo "$NUM"
6 fi
NUM was being set to the number plus the text that follows. The print $1 will print the 1st argument from the line.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:05 AM
09-14-2005 02:05 AM
Re: I have problem in scripting
if [ $NUM" -gt 70 ]
then
.
.
.
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:06 AM
09-14-2005 02:06 AM
Re: I have problem in scripting
if [ "$NUM" -gt 70 ]
then
.
.
.
fi
oops I missed one myself
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:10 AM
09-14-2005 02:10 AM
Re: I have problem in scripting
---------------- sample --------------------
integer NUM=`df -k /var |awk '/allocation used/ {print $1}'`
if [[ ${NUM} -gt 70 ]]; then
echo "${NUM}"
fi
---------------- sample --------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:14 AM
09-14-2005 02:14 AM
Re: I have problem in scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:15 AM
09-14-2005 02:15 AM
Re: I have problem in scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:16 AM
09-14-2005 02:16 AM
Re: I have problem in scripting
NUM=`df -k /stand |awk '/allocation used/'`
echo $NUM
returns something like:
52 % allocation used
which is not just numeric
you should use
NUM=`df -k /stand |awk '/allocation used/{print $0}'`
instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:17 AM
09-14-2005 02:17 AM
Re: I have problem in scripting
echo "Over 70 percent /tmp" | mailx -s "70% problem" joeuser@company.com
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:19 AM
09-14-2005 02:19 AM
Re: I have problem in scripting
.
.
NUM=df -k /var |awk '/allocation used/{print $1}'
if [ $NUM -gt 70 ]
then
echo "/var is above 70% utilized" |mailx email@address
fi
.
.
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:23 AM
09-14-2005 02:23 AM
Re: I have problem in scripting
i am learning too much from u guys