- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: help regarding bdf output shell script !!!!
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
Discussions
Discussions
Forums
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
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
тАО11-16-2007 12:56 AM
тАО11-16-2007 12:56 AM
I have written a funtion which taken bdf output and put's in a file.
The idea is to get all areas greater than 80% and echo the same on the system once they have reached 80 % limit. However the script I have written fails with the error.
The script is :-
======================================
output ()
{/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 80 ]]
then
echo "File syste Full - `hostname`:$dir is at $percent%"
fi
done} < /tmp/bdflist
output
panic
===========================================
+ awk $0 !~ /^F/
+ awk {print $5"\t" $6}
+ sed s/%//
+ 1> /tmp/bdflist}
./test[8]: Syntax error at line 9 : `do' is not expected.
Please assist in resolving the same.
Thanking you in advance
Solved! Go to Solution.
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 01:03 AM
тАО11-16-2007 01:03 AM
Re: help regarding bdf output shell script !!!!
$mailto = 'some@email_addr.com';
$hostname = `hostname`;
@mounts = `bdf`; #puts bdf info into seperate array elements
foreach (@mounts){
if ($_ =~ /100%|9[0-9]|8[0-9]%/) {
$fs = $';
chop $fs;
$mesg .= "$fs is at $&.\n";
}
}
if ($mesg) {
`echo "$mesg" | mailx -s "$hostname Filesystem Warning" $mailto`;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 01:03 AM
тАО11-16-2007 01:03 AM
Re: help regarding bdf output shell script !!!!
{
/usr/bin/bdf -l |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'/''/' >/tmp/bdflist
}
panic ()
{
cat /tmp/bdflist | while read percent dir
do
if [[ $percent -ge 80 ]]
then
echo "File syste Full - `hostname`:$dir is at $percent%"
fi
done
}
output
panic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 01:08 AM
тАО11-16-2007 01:08 AM
Solution($_ =~ /100%|9[0-9]|8[0-9]%/)
should be
($_ =~ /100%|9[0-9]%|8[0-9]%/)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 01:12 AM
тАО11-16-2007 01:12 AM
Re: help regarding bdf output shell script !!!!
/usr/bin/bdf -l |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'/''/'|
while read percent dir
do
if [[ $percent -ge 80 ]]
then
echo "File syste Full - `hostname`:$dir is at $percent%"
fi
done
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 01:38 AM
тАО11-16-2007 01:38 AM
Re: help regarding bdf output shell script !!!!
The simple fix, is to place the curly braces for each function on a line by themselves:
...
output ()
{
/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 80 ]]
then
echo "File syste Full - `hostname`:$dir is at $percent%"
fi
done
} < /tmp/bdflist
output
panic
...
This script could/should be rewritten to eliminate using temporary files (pipe output to the 'read') and should let ONE 'awk' do the work of matching and extracting (consider using 'awk's 'split').
For a simple script like this, in-lining your code like Geoff suggested is probably a more-readable approach.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 01:43 AM
тАО11-16-2007 01:43 AM
Re: help regarding bdf output shell script !!!!
include a shell interpreter and a few newlines:
#!/usr/bin/sh
output ()
{
/usr/bin/bdf -l |awk '$0 !~ /^F/' |awk '{print $5"\t" $6}'| sed 's/'%'/''/' >/tm
p/bdflist
}
panic ()
{
while read percent dir
do
if [[ $percent -ge 80 ]]
then
echo "File syste Full - `hostname`:$dir is at $percent%"
fi
done < /tmp/bdflist
}
output
panic
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 02:54 AM
тАО11-16-2007 02:54 AM
Re: help regarding bdf output shell script !!!!
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1124262
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 03:36 AM
тАО11-16-2007 03:36 AM
Re: help regarding bdf output shell script !!!!
bdfmegs -qP 90
Only the mountpoints that are greater than or equal to 90% full will be shown.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 04:26 AM
тАО11-16-2007 04:26 AM
Re: help regarding bdf output shell script !!!!
Bill Hassell, sysadmin