BDF Panic script...

I have another script which I found also on the net.

I keep getting an error:confused::

Here is the script for it:

{/usr/bin/bdf -l |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'//' >/tmp/b
dflist}

panic ()
{while read percent dir; do
        if [[ $percent -ge 70 ]]        
        then        
                echo "File System Full - `hostname`:$dir is at $percent%"
        fi        
done < /tmp/bdflist
}
output
panic

I keep trying different things, like put a space in between do and ; but nothing works. Can someone help me with this?

Thank you

Hi.

A space between { and while might fix it.

1 Like
# !/bin/bash
output()
{
   ls -l /var/tmp |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'//' >/tmp/bdflist
   }

panic ()
{
    while read percent dir
    do
    if [[ $percent -ge 70 ]]
    then
      echo "File System Full - `hostname`:$dir is at $percent%"
    fi
   done < /tmp/bdflist
}

output
panic
1 Like

Hmmm,

It gives me an output but the percentages are in thousands..

Ex:

I think the date is off too...

I don't use HP-UX, so don't know what format bdf will give you. You might just be "awking" the wrong fields?

Or, it displays date when it should display directory...

I've never seen a df that displays the date!

edit: Ah, I see it now! Post #3 mentioned ls. Not sure what that has to do with df, though. Perhaps it's an HP-UX thing?

Not sure either. I use HP-UX. I think df is a Linux command if I'm not mistaken.

Thanks anyway,

:wall:

try du -h and awk for the correct fields.

You are somewhat mistaken. df is a Unix command, originally. Linux uses the same name, too.

HP-UX is the only system I know that uses bdf.

"Thanks anyway" and banging your head against a wall won't solve your problem, but if you give up that easily, then...

Thank you scottn,

Sorry it's been one of those days. Still in the beginning process of learning UNIX...

Not gonna give up though...:smiley:

Thank you

what is the output you get when you run

/usr/bin/bdf  |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'//'
hostname(root):/home/izivanov#  /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'//'   <
9       /
9       /stand
32      /workdb
17      /var
12      /var/log
2       /var/dlctmp
6       /var/db
9       /var/applogs
8       /usr
40      /usr/openv
1       /tmp
40      /scratch
22      /opt
4       /opt/qjdjava
53      /opt/rex
1       /opt/oracle
6       /opt/ohd
86      /opt/dlc102b03
4       /home3

etc
etc
        
/home   
        
/opt/enroll/src 
        
/var/public     
        
/var/kfilled

... back to the beginning. Ignore Post because #3 it introduces lots of errors.

The only problems with post #1 were the unwanted {} pair on line 1 and the position of the { in the function (which somebody pointed out).

/usr/bin/bdf -l |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'//' >/tmp/bdflist

panic ()
{
while read percent dir; do
        if [[ $percent -ge 70 ]]
        then
                echo "File System Full - `uname -n`:$dir is at $percent%"
        fi
done < /tmp/bdflist
}
panic

Ps: I changed "hostname" to "uname -n" because the "hostname" command is dangerous (much too easy to change the name of the host).

HP-UX has both "df" and "bdf".
"df -kP" and "bdf -l" output the same fields in the same order but with subtle layout differences.

1 Like

Wow,

Very nice,

Thank you so much. It worked like a charm. now to dissect what you've changed. I want to learn how to do this better.

Thank you for your input methyl.

Thank you all for your help,

---------- Post updated at 08:46 AM ---------- Previous update was at 08:19 AM ----------

I keep getting an error on the output part of the script on the bottom.

I took it out. What does output have to do with the script. It still gives me the same output without the error though.

Thanks.

I've removed the line "output" from my post. It came from post #1 .

With hindsight I realise that the first line of the script in post #1 is missing and would probably have been part of a function called "output". The poster in post #3 twigged this but broke the script with the addition of "ls".
The function "output" would only have worked if the {} characters were in the right place. There are other variations in the syntax for a function - including just leaving white space after the { as an earlier poster suggested.

output ()
{
bdf ........
}
output ()
{ bdf ........
}
1 Like

Cool thank you...