Cover V09, I10
New Messages


New Messages

From: Matthew Cheek (
Subject: Aug 2000 article comment

I wish to comment on a statement in the article “Logical Volume Manager for Linux”, by Rafeeq Ur Rehman in the August 2000 issue of Sys Admin. In the second paragraph, Mr. Rehman states: “HP-UX and Digital UNIX use the OSF version of LVM, while Solaris uses Veritas.”

While a quick glance at the HP-UX Web site indicates that HP-UX 10 and 11 use an “OSF-defined Logical Volume Manager”, Digital UNIX (or rather, Compaq Tru64 UNIX) does not. The Tru64 UNIX logical volume manager is Logical Storage Manager (LSM) which is, in fact, an OEM'ed version of the Veritas Volume Manager (VM). In the Solaris environment, systems administrators have two logical volume manager choices: Solstice DiskSuite (SDS) and Veritas VM. Additionally, SDS and VM are not mutually exclusive and can co-exist on the same Solaris system. For example, I have administered Solaris systems where SDS is used to managed the boot disk(s), and VM is used to manage application and data volumes. Finally, while the HP-UX LVM is tightly integrated into the operating system (i.e., you can't not use it), logical volume managers are currently optional (and sometime extra cost) add-on products for Compaq Tru64 UNIX, Sun Solaris, and Linux.

Other than this very minor error, this article proved to be a very well presented introduction to the Linux LVM.

Matthew Cheek
Sr. UNIX System Administrator
Medical Archival Systems, Inc.

To the best of my knowledge the OSF version served as base for original digital UNIX LVM. However different names were adopted by different companies. This is also mentioned on Linux LVM Web page: I am not sure about the OEM version used by Compaq.

Rafeeq Ur Rehman

From: Dan Singer (
Subject: Your article on cmdline-options

I enjoyed your article “Processing Command-Line Options in the Shell”. I do a lot of shell scripting, and I never use getopts due to the limitations you mention and others. Usually, for most scripts, I just use a “while” loop, similar to your Listing #2. But when I want to get really fancy (like for a script that I'm going to tell a lot of people about), I use something like the code that's included in the attachment. It provides a lot of option processing flexibility, very similar to what you get with typical, compiled UNIX commands. It can also be easily modified for particular situations. If you don't already have some code like this laying around, I hope that you might find this useful.


# newopts: options handling code
# 8/97, D.Singer

PROG='basename $0'
USAGE="Usage: $PROG ..."
SYNTAX="_$PROG: option syntax error."

# platform specific settings
SYS="'uname -sr'"      # OS type
case "$SYS" in
  "SunOS "*)

syntax_error() {
echo "$SYNTAX" >&2
echo "$USAGE" >&2
exit 1

arg_syntax_check() {
[ "$1" -lt 1 ] && syntax_error

while [ "$#" -gt 0 ]; do
case "$OPT" in
  # options without argument
  # options with argument
      arg_syntax_check "$#"
  # ...
  # options with long names
  # ...
  # end of options

        # unknown option
  # compound option
      # break up a compound option
          OPT_STR = "'"$OPT"'";
          LEN = length(OPT_STR);
          NEW_OPTS = "";
          STATUS = 0;
          for (POS=2; POS+0 <= LEN; ++POS) {
              OPT = substr(OPT_STR,POS,1);
              if (OPT !~ /[a-zA-Z0-9_]/)
                  STATUS = 1;
              NEW_OPTS = NEW_OPTS " -" OPT;
          print NEW_OPTS;
          exit STATUS;
        }' <&-' || {
      set -- $NEW_OPTS ${1:+"$@"}
  # end of options, just command arguments left


From: Henk M. Keller (
Subject: Your article on cmdline-options

Dear Mr. Schaefer,
I read your article on processing command-line options in shell files in the July issue of Sys Admin. A good idea to pay attention to that subject!

I would like to make some remarks on the second script (

1. As far as I can see, your script stumbles on a command line like: -PARM

because it will try to do two “shift”s with only one argument available.

2. You use the command cut to split -PARM and the value. This is an extra process. They are not really expensive, but using the Korn shell (or bash or zsh and the like) this can be done without an extra process:

3. When giving examples, I would prefer to supply complete examples. Therefore, I would prefer to give an error message like:

   echo >&2 "$0: Illegal Command-line Option"
   exit 1

(including the name of the script, sending the message to stderr and exiting with a value unequal to zero).

Your third example ( could be constructed easier, again without using any extra process (awk is a beautiful, but rather expensive tool). I think your awk programs are very complex for such an easy job!

My solution would be:

 1  #!/bin/ksh
 2  # Keyword parameter demo
 3  #       Accepts arguments like
 4  #               F1=value
 5  #               F1= value
 6  #               F1 =value
 7  #               F1 = value
 8  # (c) 2000 AT Computing, Henk Keller
 9  status=         # empty: nothing seen
10                  # p     up to parameter name seen
11                  # pe    up to equals sign seen
12                  # pev   up to value seen
13  while [ "$#" -gt 0 ]
14  do
15          case "$status$1" in
16          F1)
17                  status="p"
18                  shift
19                  ;;
20          F1=)
21                  status="pe"
22                  shift
23                  ;;
24          F1=*)
25                  status="pev"
26                  F1=${1#F1=}  # in sh: F1='expr "$1 : '...\(.*\)''
27                  shift
28                  ;;
29          pe*)
30                  status="pev"
31                  F1="${1}"
32                  shift
33                  ;;
34          p=)
35                  status="pe"
36                  shift
37                  ;;
38          p=*)
39                  status="pev"
40                  F1=${1#=}    # in sh: F1='expr $1 : '.\(.*\)''
41                  shift
42                  ;;
43          *)
44                  echo>&2 "$0: Unknown argument '$1'"
45                  exit 1
46          esac
47  done
49  case "${status}" in
50  p|pe)
51          echo>&2 "$0: missing value for F1"
52          exit 2
53          ;;
54  pev)
55          echo "$0: The value for F1 is '$F1'"
56          exit 0
57          ;;
58  esac

In this script, only line 26 and 40 are Korn shell specific; an sh-replacement is given as well.

Kind regards,
Henk Keller

Thank you both for your constructive criticism of my cmdline options article in July
Sys Admin. It looks as if both of you have investigated this problem more in depth than I.

Henk: Your solution to this problem is admirable, and I will keep this available, but the scripts I write MUST be Bourne compatible. I do admit to being something of an awk snob. I'm trying to rectify that by learning Perl.

Again, thank you for your time.

Ed Schaefer