home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- subject: v11i091: ddf, a fancy disk free display for Xenix
- from: davidsen@crdos1.crd.ge.com
- organization: GE Corporate R&D Center
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 11, Issue 91
- Submitted-by: davidsen@crdos1.crd.ge.com
- Archive-name: ddf/part01
-
- [uunet did the twist again over the weekend. The most annoying thing about
- it is that I have to send files over to another system in order to generate
- the archive-name database; I use a Perl v3 script, the current uunet has perl
- 2, the former one has no perl at all. sigh. That's why the delays. ++bsa]
-
- The Xenix df display has several forms which range from incomplete to
- marginally readable. Brian Fitzgerald (brian@sixbdf.UUCP) gave me a
- script to reformat the output, but I lost it and created this instead.
- It uses a few obscure features of Xenix.
-
- Note that you will want to change the ddf command to refer to where
- you store scripts, like /local/etc, and the getopt used is the Xenix
- one, not getopts in ksh.
-
- #!/bin/sh
- # shar: Shell Archiver (v1.27)
- #
- # Run the following text with /bin/sh to create:
- # ddf
- # ddf.awk
- #
- if test ! -d bin; then echo "Creating directory bin"; mkdir bin ||
- { echo "Can't create dir!"; exit 1; }
- fi
- echo "x - extracting ddf (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ddf &&
- X#!/bin/sh
- X
- X# this is where the utilities live, like /local/etc
- XUTIL=$HOME/utils
- Xerror=false
- X
- X# see if options wanted
- Xset -- `getopt ih $*` || error=true
- X
- Xinodes=false
- X
- Xwhile [ $# -gt 0 ]
- Xdo case $1 in
- X -i) inodes=true;;
- X -h) error=true;;
- X --) break;;
- X esac
- X shift
- Xdone #
- X
- X# check argument count valid
- Xif [ $# -gt 1 ]
- Xthen error=true
- X echo "Invalid argument(s) - none expected"
- Xfi #
- X
- Xif $error
- Xthen echo "Usage:"
- X echo " ddf [-i]"
- X echo "The option -i causes the free inodes to be displayed"
- X exit 1
- Xfi #
- X
- Xecho
- Xdf -t | awk -f ${UTIL}/ddf.awk inodes=${inodes} -
- SHAR_EOF
- chmod 0755 ddf || echo "restore of ddf fails"
- if test ! -d utils; then echo "Creating directory utils"; mkdir utils ||
- { echo "Can't create dir!"; exit 1; }
- fi
- echo "x - extracting ddf.awk (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ddf.awk &&
- X#!/bin/awk
- X
- X# reformat output of df -t
- X
- XBEGIN {
- X inodes = (inodes == "true")
- X printf( "Mount free MB tot MB free %")
- X if (inodes) printf(" inodes")
- X print ""
- X}
- X
- X/total/ {
- X # add to total and output
- X match($0, "[1-9][0-9]*")
- X total = $2/2048
- X printf("%-20s %6.2f %6.2f %6.1f%%",
- X partname, psize, total, 100*psize/total)
- X if (inodes)
- X printf(" %6d", ino_count)
- X print ""
- X continue
- X}
- X
- X/blocks/ {
- X # break out the sizes and mount point
- X n = match($0,"[ (]")
- X partname = substr($0, 1, n-1)
- X n = match($0, ":")
- X split(substr($0, n+1), flds)
- X psize = flds[1]/2048
- X ino_count = flds[3]
- X}
- SHAR_EOF
- chmod 0644 ddf.awk || echo "restore of ddf.awk fails"
- exit 0
- --
- bill davidsen (ibmbin-request@crdgw1.crd.ge.com, uunet!crdgw1!ibmbin-request)
- moderator c.b.i.p newgroup and 386users mailing list.
- binary submissions to ibmbin@crdgw1.crd.ge.com (uunet!crdgw1!ibmbin)
- "Stupidity, like virtue, is its own reward" -me
-
-