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?
# !/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
... 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.
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.