<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: getopt in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064142#M94595</link>
    <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;in addition to SEP and JRF:&lt;BR /&gt;If you have to deal with plain parameters as well, don't forget to reset the argument list.&lt;BR /&gt;&lt;BR /&gt;while getopts :al:L:n op&lt;BR /&gt;do&lt;BR /&gt;  case $op in&lt;BR /&gt;  a|n) ${op}flag=y ;;&lt;BR /&gt;  l) ${op}flag=$OPTIND&lt;BR /&gt;     if [ "$Lflag" ]; then print -u2 'mutually exclusive option -l|-L ...'; exit 2;;&lt;BR /&gt;  L) ${op}flag=$OPTIND&lt;BR /&gt;     if [ "$lflag" ]; then print -u2 'mutually exclusive option -l|-L ...'; exit 2;;&lt;BR /&gt;  ?) print -u usage ;;&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;# reset arglist&lt;BR /&gt;shift $((OPTIND-1))&lt;BR /&gt;&lt;BR /&gt;typeset -i p=0&lt;BR /&gt;for i   # all remaining parameters&lt;BR /&gt;do&lt;BR /&gt;   print param$((p+=1))="'$i'"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
    <pubDate>Sun, 02 Sep 2007 11:59:09 GMT</pubDate>
    <dc:creator>Peter Nikitka</dc:creator>
    <dc:date>2007-09-02T11:59:09Z</dc:date>
    <item>
      <title>getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064138#M94591</link>
      <description>Hello ppl,&lt;BR /&gt;on unix shell scripting (bash, ksh, sh)&lt;BR /&gt;does anyone know how can I use getopt in order to examine command line parameters? &lt;BR /&gt;I couldn't find any helpfull info on man pages or other places on the web...&lt;BR /&gt;thanks&lt;BR /&gt;Itai.&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Sep 2007 04:06:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064138#M94591</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2007-09-02T04:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064139#M94592</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;while getopts d:n:f:r:l: opt&lt;BR /&gt;do&lt;BR /&gt;  case "$opt" in&lt;BR /&gt;  d) dflg=1&lt;BR /&gt;    DELAY=$OPTARG;;&lt;BR /&gt;  r) rflg=1&lt;BR /&gt;    RUNS=$OPTARG;;&lt;BR /&gt;  n) nflg=1&lt;BR /&gt;    NUM=$OPTARG;;&lt;BR /&gt;  l) lflg=1&lt;BR /&gt;    LF=$OPTARG;;&lt;BR /&gt;  f) nflg=1&lt;BR /&gt;    FILTER=$OPTARG;;&lt;BR /&gt;  ?) out_help&lt;BR /&gt;    exit ;;&lt;BR /&gt;  esac&lt;BR /&gt;done 2&amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpuxconsulting.com/mem.mon" target="_blank"&gt;http://www.hpuxconsulting.com/mem.mon&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This script is in it's late beta stages, a memory leak monitor for HP-UX, Solaris and Linux.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Sun, 02 Sep 2007 05:14:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064139#M94592</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-09-02T05:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064140#M94593</link>
      <description>ok,&lt;BR /&gt;if I have two switches that are conflicts each other (like -l and -L on lvcreate command...)  how can I check it with getopts?&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Sep 2007 05:48:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064140#M94593</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2007-09-02T05:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064141#M94594</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; if I have two switches that are conflicts each other (like -l and -L on lvcreate command...) how can I check it with getopts?&lt;BR /&gt;&lt;BR /&gt;Notice in the example given that as each switch is seen that a variable is set denoting that.  Hence, after 'getopt' runs, write tests like:&lt;BR /&gt;&lt;BR /&gt;if [ "$l_flag" = 1 -a "$L_flag" = 1 ]; then&lt;BR /&gt;    print -u2 "Error: '-l' and '-L' are mutually exclusive"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Since errors should be directed to STDERR I used 'print -u2' to target that file descriptor (FD2).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 02 Sep 2007 08:09:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064141#M94594</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-02T08:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064142#M94595</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;in addition to SEP and JRF:&lt;BR /&gt;If you have to deal with plain parameters as well, don't forget to reset the argument list.&lt;BR /&gt;&lt;BR /&gt;while getopts :al:L:n op&lt;BR /&gt;do&lt;BR /&gt;  case $op in&lt;BR /&gt;  a|n) ${op}flag=y ;;&lt;BR /&gt;  l) ${op}flag=$OPTIND&lt;BR /&gt;     if [ "$Lflag" ]; then print -u2 'mutually exclusive option -l|-L ...'; exit 2;;&lt;BR /&gt;  L) ${op}flag=$OPTIND&lt;BR /&gt;     if [ "$lflag" ]; then print -u2 'mutually exclusive option -l|-L ...'; exit 2;;&lt;BR /&gt;  ?) print -u usage ;;&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;# reset arglist&lt;BR /&gt;shift $((OPTIND-1))&lt;BR /&gt;&lt;BR /&gt;typeset -i p=0&lt;BR /&gt;for i   # all remaining parameters&lt;BR /&gt;do&lt;BR /&gt;   print param$((p+=1))="'$i'"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sun, 02 Sep 2007 11:59:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064142#M94595</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-09-02T11:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064143#M94596</link>
      <description>There is info under ksh(1) and sh-posix(1).  It also has its own man page, getopt(1) and getopts(1), getopt(3):&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-60130/getopts.1.html" target="_blank"&gt;http://docs.hp.com/en/B2355-60130/getopts.1.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-60130/getopt.1.html" target="_blank"&gt;http://docs.hp.com/en/B2355-60130/getopt.1.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-60130/getopt.3C.html" target="_blank"&gt;http://docs.hp.com/en/B2355-60130/getopt.3C.html&lt;/A&gt;</description>
      <pubDate>Sun, 02 Sep 2007 12:37:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064143#M94596</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-02T12:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064144#M94597</link>
      <description>can I use getopts with switches that has more than one character? (like -itai)&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Sep 2007 13:43:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064144#M94597</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2007-09-02T13:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064145#M94598</link>
      <description>&amp;gt;can I use getopts with switches that has more than one character? (like -itai)&lt;BR /&gt;&lt;BR /&gt;Not directly.  You would have to have -i with a parm that is "tai".  Or you would have to leave out -i and process it as an illegal option.</description>
      <pubDate>Sun, 02 Sep 2007 14:06:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064145#M94598</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-02T14:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064146#M94599</link>
      <description>Hi (again) Itai:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; can I use getopts with switches that has more than one character? (like -itai)&lt;BR /&gt;&lt;BR /&gt;No, 'getopt' and 'getopts' are single-character oriented.  Perl offers a 'Getopt::Long' module where options are introduced with double dashes and can have long names, like '--help' or '--verbose'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 02 Sep 2007 14:13:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064146#M94599</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-02T14:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064147#M94600</link>
      <description>read this excellent guide on shelldorado for some more info.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.shelldorado.com/goodcoding/cmdargs.html" target="_blank"&gt;http://www.shelldorado.com/goodcoding/cmdargs.html&lt;/A&gt;</description>
      <pubDate>Mon, 03 Sep 2007 02:04:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064147#M94600</guid>
      <dc:creator>dirk dierickx</dc:creator>
      <dc:date>2007-09-03T02:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: getopt</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064148#M94601</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;in (another) addition to JRF regarding the usage of multi-character-options:&lt;BR /&gt;If you supply somthing like '-ita' AND NONE of the options is defined to get a parameter, all of the options i,t,a are set.&lt;BR /&gt;Try with my (corrected) testscript:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;while getopts :al:L:n op&lt;BR /&gt;do&lt;BR /&gt;  case $op in&lt;BR /&gt;  a|n) eval ${op}flag=y ;;&lt;BR /&gt;  l) eval ${op}flag=$OPTARG&lt;BR /&gt;     if [ "$Lflag" ]; then print -u2 'mutually exclusive option -l|-L ...'; exit 2;fi ;;&lt;BR /&gt;  L) eval ${op}flag=$OPTARG&lt;BR /&gt;     if [ "$lflag" ]; then print -u2 'mutually exclusive option -l|-L ...'; exit 2;fi ;;&lt;BR /&gt;  ?) print -u usage ;;&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;# reset arglist&lt;BR /&gt;shift $((OPTIND-1))&lt;BR /&gt;&lt;BR /&gt;typeset -i p=0&lt;BR /&gt;for i   # all remaining parameters&lt;BR /&gt;do&lt;BR /&gt;   print param$((p+=1))="'$i'"&lt;BR /&gt;done&lt;BR /&gt;print Flags:&lt;BR /&gt;set | fgrep flag=&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;opt.ksh -anL val&lt;BR /&gt;Flags:&lt;BR /&gt;Lflag=val&lt;BR /&gt;aflag=y&lt;BR /&gt;nflag=y&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 03 Sep 2007 04:23:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getopt/m-p/4064148#M94601</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-09-03T04:23:59Z</dc:date>
    </item>
  </channel>
</rss>

