| oct2000.tar |
New Messages
From: Matthew Cheek (cheek@mars-system.com) 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
Matthew, Rafeeq Ur Rehman
From: Dan Singer (des@cs.duke.edu)
Ed-
Regards,
#!/bin/sh
# newopts: options handling code
#
# 8/97, D.Singer
PROG='basename $0'
USAGE="Usage: $PROG ..."
SYNTAX="_$PROG: option syntax error."
#
# platform specific settings
#
AWK="awk"
SYS="'uname -sr'" # OS type
case "$SYS" in
"SunOS "*)
AWK="nawk"
esac
syntax_error() {
echo "$SYNTAX" >&2
echo "$USAGE" >&2
exit 1
}
arg_syntax_check() {
[ "$1" -lt 1 ] && syntax_error
}
while [ "$#" -gt 0 ]; do
OPT="$1"
case "$OPT" in
# options without argument
-a)
AFLAG=1
;;
# options with argument
-c)
shift
arg_syntax_check "$#"
CARG="$1"
CFLAG=1
;;
# ...
# options with long names
--long)
LONG_FLAG=1
;;
# ...
# end of options
--)
shift
break
;;
--*)
syntax_error
;;
# unknown option
-?)
syntax_error
;;
# compound option
-??*)
# break up a compound option
NEW_OPTS='$AWK 'BEGIN {
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;
}' <&-' || {
syntax_error
}
shift
set -- $NEW_OPTS ${1:+"$@"}
continue
;;
# end of options, just command arguments left
*)
break
esac
shift
done
#ARGV="$*"
From: Henk M. Keller (henk@ATComputing.nl)
Dear Mr. Schaefer,
I would like to make some remarks on the second script (option.sh): 1. As far as I can see, your script stumbles on a command line like:
option.sh -PARM because it will try to do two shifts 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:
PARM=${1#-PARM}
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 (keyword.sh) 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
48
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/Dan: 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 |