LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 06-11-2008, 02:18 AM   #1
linuxshadow
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
Issue with Script??


root@testdb /]# cat /u01/BACKUP/scripts/filespace.sh
#!/bin/bash
# This script can be used to
# warn the users that
# the file system is getting full
#
# Script needs adjusted for your
# needs. Below is set to monitor
# all the file systems mounted and report to
# RECEIVER
#
# Usage: as a cron entry for best use.


RECEIVER=ITOPS.SSI@oracle.com

for fs in `df -k|awk '{print $1}'|sed -n "3,14 p"`
do
x=`df -kl | grep $fs | awk '{ print $5 }'`
y=50%

if [ $x -gt $y ]
then
message="File System `df -k |grep $fs |awk '{print $6\",\"$5}'` Full!!!"
echo $subject
echo $message | mailx -s "`hostname` - File System Full
Warning !!!" $RECEIVER
fi
done
[root@testdb /]#
-----------------------------------

[root@testdb /]# ./u01/BACKUP/scripts/filespace.sh
./u01/BACKUP/scripts/filespace.sh: line 21: [: 12%: integer expression expected
./u01/BACKUP/scripts/filespace.sh: line 21: [: 0%: integer expression expected
./u01/BACKUP/scripts/filespace.sh: line 21: [: 2%: integer expression expected
./u01/BACKUP/scripts/filespace.sh: line 21: [: 96%: integer expression expected
./u01/BACKUP/scripts/filespace.sh: line 21: [: 91%: integer expression expected
[root@testdb /]#

How to i resolve this error.

--
 
Old 06-11-2008, 02:28 AM   #2
jpwigan
LQ Newbie
 
Registered: Jun 2008
Distribution: RHEL, Fedora, Gentoo, Slackware
Posts: 27

Rep: Reputation: 15
-gt expects numeric inputs. "50%" is not a numeric input, but "50" is. You need to strip the % sign out of your input before testing against it.

So, instead of:

y=50%

You would use:

y=50

and to strip the % out in the x line, add a pipe to your favorite regex engine. My example uses sed:

x=`df -kl | grep $fs | awk '{ print $5 }' | sed 's/%//'`

For perl, it's identical except for the command:

x=`df -kl | grep $fs | awk '{ print $5 }' | perl -pe 's/%//'`
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script Issue ryanbrimmer Linux - Newbie 1 06-16-2007 05:23 AM
sh script issue. UltraSoul Solaris / OpenSolaris 4 03-29-2007 05:31 PM
Simple script issue...I think chiquitomuir Linux - Newbie 4 09-22-2006 10:02 PM
Issue with my backup script gauge73 Linux - General 7 02-23-2004 08:54 PM
Script Issue gauge73 Linux - General 8 07-14-2003 09:50 AM


All times are GMT -5. The time now is 09:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration