i am trying to to do this in tcsh shell but i can't find some command to do this;
while getopts 'w:c:hp' OPT; do
case $OPT in
w) WARN=$OPTARG;;
c) CRIT=$OPTARG;; #this is in bash
h) hlp="yes";;
p) perform="yes";;
*) unknown="yes";;
esac
done
set argv=`getopt 'w:c:hp' $*`
set errcode=$?
if ( $errcode != 0 ) then
echo 'Args please'
exit 2
endif
set WARN CRIT hlp perform unknown
while (1)
switch($1)
case -w:
set WARN=$2; shift; shift; breaksw
case -c:
set CRIT=$2; shift; shift; breaksw
case -h:
set hlp="yes"; shift ; breaksw;
case -p:
set perform="yes"; shift; breaksw;
case --:
shift; break;
default:
set unknown="yes"; break;
endsw
end
echo WARN=$WARN
echo CRIT=$CRIT
echo hlp=$hlp
echo perform=$perform
echo unknown=$unknown
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.