Hello,
I've written a script which is a wrapper around mount.cifs. IT's called
by the automounter, which passes some
paremteres to it.
It's neccesary for this script to determine these parameters. The first
are easy:
$1 is the key
$2 is the mountdirectory
and mountoptions are after -o .
I've written code that does discover these options and looks for the
option AUTOFS_USER:
MOUNT_options=""
while [ ! -z "$1" ]; do
if [ "$1" = "-o" ]; then
shift
MOUNT_options="$1"
break
fi
shift
done
if [ -z "$MOUNT_options" ]; then
do_log "No options found."
exit 1
else
MOUNT_option=""
ncount=1
while [ $ncount -lt 20 ]; do
MOUNT_option=$(echo $MOUNT_options | cut --delimiter ','
--fields $ncount)
if [ -z "$MOUNT_option" ]; then
break
elif [ $(echo "$MOUNT_option" | grep "AUTOFS_USER" | wc --chars)
-gt 0 ]; then
AUTOFS_USER="$(echo $MOUNT_option | cut --delimiter='='
--fields=2 --only-delimited)"
break
fi
let "ncount++"
done
fi
Now this works very good, but I'm just looking for a shorter way, with
awk for example. Any one
an idea to do this looking for a field in a list of fields seperated by
a comma. This field has some properties
(it has the form AUTOFS_USER=....).
Thanks in advance,
Stef Bon
--
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page