i have the following code:
while getopts s:h:w:c:t:p option
do
case "${option}"
in
s) CUSTOM_COMMSTR=${OPTARG};;
h) CUSTOM_HOSTADDRESS=${OPTARG};;
w) CUSTOM_WARNING=${OPTARG};;
c) CUSTOM_CRITICAL=${OPTARG};;
t) CUSTOMTYPE="${OPTARG}";;
p) CUSTOM_PARTITION=${OPTARG};;
esac
done
which generally works for me. my script runs like this:
./script.sh -s blah@h -h 127.0.0.1 -w 50 -c 60 -t -IFS -p /
when I run this script, it bails on the "-t -IFS". It complains that "illegal option I, illegal option F, illegal option S. I tried removing the "-" from the "-IFS" and still, no luck. I need to be able to pass multiple characters as is shown in my example. I googled getopts and I couldnt quite find a solution that addresses my exact problem.
can someone please help correct my problem?
OS: CentOS
EDIT:
this is not a duplicate. I'm asking about "getopts" not "getopt".