DiskSpace Error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting DiskSpace Error
# 1  
Old 03-06-2013
Wrench DiskSpace Error

Hi,

While am preparing the script for diskspace for different partitions different threshhold limit. am getting below error:
Code:
./test.sh: syntax error at line 5: `space=$' unexpected

Script
====
Code:
#!/bin/sh
df -h |grep -v '/oradata2'|grep -v '/orabkp' |grep -v '/oradata5' | awk '{ print $5 " " $6 " " $4 }' | while read output;
#df -h |grep -v '/oradata2'|awk '{ print $5 " " $6 " " $4 }' | while read output;
do
th=80
space=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
echo $space >> space.log
echo $capacity >> capa.log
partition=$(echo $output | awk '{ print $2 }' )
available=$(echo $output | awk '{ print $3 }' )
if [[ $space -gt $th ]] ;
then
echo " \" $partition partition has crossed over $space% of its capacity, available space is $available" >> log.log

fi
done

Please advise me how to resolve this...

Last edited by radoulov; 03-06-2013 at 07:25 AM.. Reason: Code tags!
# 2  
Old 03-06-2013
can you paste the output of below command here:

Code:
df -h |grep -v '/oradata2'|grep -v '/orabkp' |grep -v '/oradata5'

# 3  
Old 03-06-2013
declare th outside d function
# 4  
Old 03-06-2013
Quote:
Originally Posted by nikhil jain
declare th outside d function
Why? What significance does it have?
# 5  
Old 03-06-2013
Code:
df -h |grep -v '/oradata2'|grep -v '/orabkp' |grep -v '/oradata5' | awk '{ print $5 " " $6 " " $4 }' > abcd

while read line;
#df -h |grep -v '/oradata2'|awk '{ print $5 " " $6 " " $4 }' | while read output;
do
th=80
space=$(echo $line | awk '{ print $1}' | cut -d'%' -f1 )
echo $space >> space.log
echo $capacity >> capa.log
partition=$(echo $line | awk '{ print $2 }' )
available=$(echo $line | awk '{ print $3 }' )
if [[ $space -gt $th ]] ;
then
echo " \" $partition partition has crossed over $space% of its capacity, available space is $available" >> log.log

fi
done < abcd


Last edited by radoulov; 03-06-2013 at 07:26 AM.. Reason: Code tags!
# 6  
Old 03-06-2013
Wrench

Quote:
Originally Posted by nikhil jain
declare th outside d function
Same error am receving even declare th value outside the function..

---------- Post updated at 04:51 PM ---------- Previous update was at 04:49 PM ----------

Quote:
Originally Posted by panyam
can you paste the output of below command here:

Code:
df -h |grep -v '/oradata2'|grep -v '/orabkp' |grep -v '/oradata5'


Code:
/dev/md/dsk/d1          20G   6.3G    13G    33%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                    85G   1.7M    85G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
sharefs                  0K     0K     0K     0%    /etc/dfs/sharetab
/dev/dsk/c1t5d5s2      492G   389G    98G    80%    /oradata3
/dev/dsk/c1t5d6s2      492G   399G    88G    82%    /oradata4


Last edited by radoulov; 03-06-2013 at 07:26 AM.. Reason: Additional code tags!
# 7  
Old 03-06-2013
You are accessing the fields wrongly!!

try some thing like this:

Code:
df -h |grep -v '/oradata2'|grep -v '/orabkp' |grep -v '/oradata5' | awk '{ print $5 " " $6 " " $4 }'  | while read output; 
 do 
 th=80; 
 space=$(echo $output | awk '{ print $(NF-1) }' | cut -d'%' -f1 ); 
 partition=$(echo $output | awk '{ print $NF }'); 
 available=$(echo $output | awk '{ print $4 }' ); 
 if [[ $space -gt $th ]] ; 
 then 
 echo " \"$partition\" partition has crossed over $space% of its capacity, available space is $available"; 
 fi; 
 done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Check free diskspace

Hi all, I would like to know what was the free disk space available in my system for last two days back. I know how to check free disk space by command below. df -h But i want to know the same outcome for last two days back. Please help me. Reg, Mastan (5 Replies)
Discussion started by: mastansaheb
5 Replies

2. Shell Programming and Scripting

[ask]elimination with diskspace

dear all, i want elimination file with disk space for example: $ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 62G 19G 41G 31% / /dev/sda1 99M 13M 82M 13% /boot tmpfs 1014M 0... (2 Replies)
Discussion started by: zvtral
2 Replies

3. Solaris

graphical diskspace analyzer

Hi all, recently I took over the admin task for a solaris 5.10 machine. Being a little bit familiar with debian systems Solaris is up to now a complete mystery to me. The first thing I would like to have is a graphical diskspace analyzer. I mean something like BaoBab under gnome. I there a... (2 Replies)
Discussion started by: sly_dunbar
2 Replies

4. Solaris

Solaris not freeign up diskspace

Hi, one of our drive was 100 utilized so I delete some files to free up some diskspace. However, when i check the diskspace, its still saying this drive is 100 % utilized. any suggestions? btw, i'm using df -h to check the diskspace (2 Replies)
Discussion started by: mrx1350
2 Replies

5. Shell Programming and Scripting

ASM Diskspace

Hi I want to check Oracle ASM disk status through a PERL script. Script flow would be like this ... 1. Its taking diskgroup name in the command line... 2. Connect to Oracle database 3. If connection error send a critical message. Plz replyyyyyyy...... (1 Reply)
Discussion started by: Harikrishna
1 Replies

6. Shell Programming and Scripting

to compute diskspace

Guys, have any idea for the script like this? also to compute w/ decimal. thanks a=10 b=20 c=30 d=40 if a < b then ( a -b)*1024 = free space b + (c -d) = total space if a > b then (b / d)*1024 = cpu (3 Replies)
Discussion started by: kenshinhimura
3 Replies

7. Shell Programming and Scripting

Limitation of DiskSpace Script

Hi, I'm a teacher in Germany and I want to set up a classroom with Linux 8.1 PCs. Every User should have a Max of 100 MB available space. Now I need a script which tells everyone how much diskspace is used in a certain subdirectory. It should work like that: User enters a command like... (1 Reply)
Discussion started by: Dansen
1 Replies

8. UNIX for Dummies Questions & Answers

Diskspace

Hi there, pls help me, i have a problem, how i can find out the disk amount of each harddisk per command (not the on label on the Harddisk) i need it on HP UX and Sun. can anybody helb me???? pls thanks Scotty (1 Reply)
Discussion started by: scotty
1 Replies

9. UNIX for Dummies Questions & Answers

Linux diskspace usage

when /var directory of my machine gets filled up (85%) i removed some old logs. but after cleaning df -k command still shows that /var is still 85% full. It can detect the actual disk space only after I restart the machine. Is there a way to force df to reflect actual free space without... (1 Reply)
Discussion started by: necro
1 Replies

10. UNIX for Dummies Questions & Answers

diskspace usage info

Anybody can help me? I need to know a specified folder diskspace usage, that's how much bytes that folder and its files/folders below spend on my storage. Thanks (2 Replies)
Discussion started by: nusajunus
2 Replies
Login or Register to Ask a Question