02-27-2006
Quote:
Originally Posted by tadakamalla
Iam working on Free BSD 5.3 version.
Now i want to check which partition if greater than 90% full without scanning the first row of record. How to do this ? Please anyone of u help me with this?
This is quick, done early in the morning, but it works. Please don't yell at my 'inefficiencies" ! :>D Streamline it as you will.
It more than likely NEEDS it BADLY.
===========
#!/bin/ksh
get_size () {
IFS="%
"
df -k | grep '\/dev\/' | awk '{ printf "%s\t%d\n",$6,$5 }'
IFS="
"
}
alm_func () {
LIM=$1
shift
NUM=`echo $#/2 | bc`
while [ $NUM -gt 0 ]
doif [ $2 -gt $LIM ]; thenecho "Partition $1 is at $2'%'."
fi
shift;
shift;
((NUM=NUM-1))
done
}
#=======
if [ $# -ne 1 ]; then
echo "$0: Invalid number of arguments"
echo "usage: $0 <filesystem utilization limit>"
exit 1
fi
LIMIT=$1
alm_func $LIMIT `get_size`
======
IFS is usually "<space><tab><\n>" I add the '%'
as a lazy way to make it a field delimiter and 'subtract' it from the 'df -k' output. Dirty, I know. :>D
==
If you want the DEVICE name, substitute '$1' for the '$6' in the AWK statement in "get_size()"
====
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi
I want to write to my output_file using:
if((fptr = creat(output_file, _S_IWRITE)) == -1)
{
printf("output_file..."..);
return (1);
}
for(...)
{
_write(fptr, buffer, BUF_SIZE);
}
It says "_S_IWRITE" undeclared!!!
Anybody knows what function I can use for that and what I... (3 Replies)
Discussion started by: lacasa
3 Replies
2. UNIX for Dummies Questions & Answers
I am on AOL now,and i am using 56 k,i was gonna install FreeBSD,but i dont know if aol works on BSD,or my modem.
Do they work on BSD? (2 Replies)
Discussion started by: kita
2 Replies
3. UNIX for Dummies Questions & Answers
i am new at unix and am VERY confused about the compression processes. what progs do i need to unzip and zip files? there must be a standard one similar to winzip? (1 Reply)
Discussion started by: Mindscan
1 Replies
4. UNIX for Dummies Questions & Answers
What is FreeBSD, who does use Free? (3 Replies)
Discussion started by: cyberangel
3 Replies
5. BSD
I want someone tell me the positives and negatives points of FreeBSD 5.2.1, if someone help me, i thanks a lot! (4 Replies)
Discussion started by: israel
4 Replies
6. BSD
B]I want the best of the best FreeBSD version for my study in Unix...please sugest me... Thanks (5 Replies)
Discussion started by: israel
5 Replies
7. BSD
I just download the FreeBSD 5.3 i386 iso files. And I have a problem now, I can't copy the 5.3-RELEASE-i386-disc2.iso to the cd, I try a lot of times, even change lots of blank cd to try but still cannot. But I can copy the other three iso files, i.e. 5.3-RELEASE-i386-bootonly.iso,... (4 Replies)
Discussion started by: GarbageKing
4 Replies
8. Programming
Hello there,
My mulithreaded application (which is too large to represent the source code here) is crashing after installing FreeBSD 7.1-RELEASE/amd64.
It worked properly on others machines (Dual Cores with 4GB of RAM - FreeBSD 6.2-RELEASE/i386).
The current machine has 2x Core 2 Duo... (1 Reply)
Discussion started by: Seenquev
1 Replies
9. Fedora
I'm using Windows mostly and the only *nix thing I used during my life was cygwin (I like command line :)).
But currently I have (by an occasion) a DVD with latest FreeBSD. I don't know why, but I want to install it...
But probably, this OS is too difficult for a beginner. I heard, it's used on... (3 Replies)
Discussion started by: TeenageWerewolf
3 Replies
LEARN ABOUT DEBIAN
cgi::pretty
CGI::Pretty(3pm) User Contributed Perl Documentation CGI::Pretty(3pm)
NAME
CGI::Pretty - module to produce nicely formatted HTML code
SYNOPSIS
use CGI::Pretty qw( :html3 );
# Print a table with a single data element
print table( TR( td( "foo" ) ) );
DESCRIPTION
CGI::Pretty is a module that derives from CGI. It's sole function is to allow users of CGI to output nicely formatted HTML code.
When using the CGI module, the following code:
print table( TR( td( "foo" ) ) );
produces the following output:
<TABLE><TR><TD>foo</TD></TR></TABLE>
If a user were to create a table consisting of many rows and many columns, the resultant HTML code would be quite difficult to read since
it has no carriage returns or indentation.
CGI::Pretty fixes this problem. What it does is add a carriage return and indentation to the HTML code so that one can easily read it.
print table( TR( td( "foo" ) ) );
now produces the following output:
<TABLE>
<TR>
<TD>foo</TD>
</TR>
</TABLE>
Recommendation for when to use CGI::Pretty
CGI::Pretty is far slower than using CGI.pm directly. A benchmark showed that it could be about 10 times slower. Adding newlines and spaces
may alter the rendered appearance of HTML. Also, the extra newlines and spaces also make the file size larger, making the files take longer
to download.
With all those considerations, it is recommended that CGI::Pretty be used primarily for debugging.
Tags that won't be formatted
The following tags are not formatted: <a>, <pre>, <code>, <script>, <textarea>, and <td>. If these tags were formatted, the user would see
the extra indentation on the web browser causing the page to look different than what would be expected. If you wish to add more tags to
the list of tags that are not to be touched, push them onto the @AS_IS array:
push @CGI::Pretty::AS_IS,qw(XMP);
Customizing the Indenting
If you wish to have your own personal style of indenting, you can change the $INDENT variable:
$CGI::Pretty::INDENT = " ";
would cause the indents to be two tabs.
Similarly, if you wish to have more space between lines, you may change the $LINEBREAK variable:
$CGI::Pretty::LINEBREAK = "
";
would create two carriage returns between lines.
If you decide you want to use the regular CGI indenting, you can easily do the following:
$CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = "";
AUTHOR
Brian Paulsen <Brian@ThePaulsens.com>, with minor modifications by Lincoln Stein <lstein@cshl.org> for incorporation into the CGI.pm
distribution.
Copyright 1999, Brian Paulsen. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Bug reports and comments to Brian@ThePaulsens.com. You can also write to lstein@cshl.org, but this code looks pretty hairy to me and I'm
not sure I understand it!
SEE ALSO
CGI
perl v5.14.2 2011-01-24 CGI::Pretty(3pm)