home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume11 / ddf / part01 next >
Encoding:
Text File  |  1990-04-03  |  3.1 KB  |  120 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v11i091: ddf, a fancy disk free display for Xenix
  3. from: davidsen@crdos1.crd.ge.com
  4. organization: GE Corporate R&D Center
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 11, Issue 91
  8. Submitted-by: davidsen@crdos1.crd.ge.com
  9. Archive-name: ddf/part01
  10.  
  11. [uunet did the twist again over the weekend.  The most annoying thing about
  12. it is that I have to send files over to another system in order to generate
  13. the archive-name database; I use a Perl v3 script, the current uunet has perl
  14. 2, the former one has no perl at all.  sigh.  That's why the delays.  ++bsa]
  15.  
  16.   The Xenix df display has several forms which range from incomplete to
  17. marginally readable. Brian Fitzgerald (brian@sixbdf.UUCP) gave me a
  18. script to reformat the output, but I lost it and created this instead.
  19. It uses a few obscure features of Xenix.
  20.  
  21.   Note that you will want to change the ddf command to refer to where
  22. you store scripts, like /local/etc, and the getopt used is the Xenix
  23. one, not getopts in ksh.
  24.  
  25. #!/bin/sh
  26. # shar:    Shell Archiver  (v1.27)
  27. #
  28. #    Run the following text with /bin/sh to create:
  29. #      ddf
  30. #      ddf.awk
  31. #
  32. if test ! -d bin; then echo "Creating directory bin"; mkdir bin ||
  33.   { echo "Can't create dir!"; exit 1; }
  34. fi
  35. echo "x - extracting ddf (Text)"
  36. sed 's/^X//' << 'SHAR_EOF' > ddf &&
  37. X#!/bin/sh
  38. X
  39. X# this is where the utilities live, like /local/etc
  40. XUTIL=$HOME/utils
  41. Xerror=false
  42. X
  43. X# see if options wanted
  44. Xset -- `getopt ih $*` || error=true
  45. X
  46. Xinodes=false
  47. X
  48. Xwhile [ $# -gt 0 ]
  49. Xdo    case $1 in
  50. X    -i)    inodes=true;;
  51. X    -h)    error=true;;
  52. X    --)    break;;
  53. X    esac
  54. X    shift
  55. Xdone    #
  56. X
  57. X# check argument count valid
  58. Xif [ $# -gt 1 ]
  59. Xthen    error=true
  60. X    echo "Invalid argument(s) - none expected"
  61. Xfi    #
  62. X
  63. Xif $error
  64. Xthen    echo "Usage:"
  65. X    echo "  ddf [-i]"
  66. X    echo "The option -i causes the free inodes to be displayed"
  67. X    exit 1
  68. Xfi    #
  69. X
  70. Xecho
  71. Xdf -t | awk -f ${UTIL}/ddf.awk inodes=${inodes} -
  72. SHAR_EOF
  73. chmod 0755 ddf || echo "restore of ddf fails"
  74. if test ! -d utils; then echo "Creating directory utils"; mkdir utils ||
  75.   { echo "Can't create dir!"; exit 1; }
  76. fi
  77. echo "x - extracting ddf.awk (Text)"
  78. sed 's/^X//' << 'SHAR_EOF' > ddf.awk &&
  79. X#!/bin/awk
  80. X
  81. X# reformat output of df -t
  82. X
  83. XBEGIN {
  84. X    inodes = (inodes == "true")
  85. X    printf( "Mount               free MB tot MB  free %")
  86. X    if (inodes) printf(" inodes")
  87. X    print ""
  88. X}
  89. X
  90. X/total/ {
  91. X    # add to total and output
  92. X    match($0, "[1-9][0-9]*")
  93. X    total = $2/2048
  94. X    printf("%-20s %6.2f %6.2f %6.1f%%",
  95. X        partname, psize, total, 100*psize/total)
  96. X    if (inodes)
  97. X        printf(" %6d", ino_count)
  98. X    print ""
  99. X    continue
  100. X}
  101. X
  102. X/blocks/ {
  103. X    # break out the sizes and mount point
  104. X    n = match($0,"[ (]")
  105. X    partname = substr($0, 1, n-1)
  106. X    n = match($0, ":")
  107. X    split(substr($0, n+1), flds)
  108. X    psize = flds[1]/2048
  109. X    ino_count = flds[3]
  110. X}
  111. SHAR_EOF
  112. chmod 0644 ddf.awk || echo "restore of ddf.awk fails"
  113. exit 0
  114. --
  115. bill davidsen (ibmbin-request@crdgw1.crd.ge.com, uunet!crdgw1!ibmbin-request)
  116.   moderator c.b.i.p newgroup and 386users mailing list.
  117.   binary submissions to ibmbin@crdgw1.crd.ge.com (uunet!crdgw1!ibmbin)
  118.             "Stupidity, like virtue, is its own reward" -me
  119.  
  120.