【问题标题】:TCSH: i need find getops in tsch shellTCSH:我需要在 tcsh shell 中找到 getopt
【发布时间】:2018-02-21 19:40:04
【问题描述】:

我正在尝试在 tcsh shell 中执行此操作,但我找不到执行此操作的命令;

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

【问题讨论】:

    标签: freebsd sensu pfsense


    【解决方案1】:
    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
    

    【讨论】:

      猜你喜欢
      • 2011-02-03
      • 2021-07-10
      • 1970-01-01
      • 1970-01-01
      • 2018-03-20
      • 2015-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多