<?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: getopts help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696737#M56948</link>
    <description>OPTIND is the index of the first argument after the options.&lt;BR /&gt;OPTARGS is the actual arguments pointed by OPTIND.&lt;BR /&gt;&lt;BR /&gt;Using getopts let you only assign arguments to flags using the "" or using ','; like:&lt;BR /&gt;-a "arg1 arg2" -b -c  OR&lt;BR /&gt;-a arg1,arg2 -b -c&lt;BR /&gt;&lt;BR /&gt;If you do not like this, i'm afraid you need to make your own program using argv,argc.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan&lt;BR /&gt;ps. If you find some other solution, please note your solution at the end of this call. It's interesting...</description>
    <pubDate>Thu, 04 Apr 2002 08:42:04 GMT</pubDate>
    <dc:creator>Ceesjan van Hattum</dc:creator>
    <dc:date>2002-04-04T08:42:04Z</dc:date>
    <item>
      <title>getopts help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696734#M56945</link>
      <description>Hi,&lt;BR /&gt;How can i pass multiple argument to getopts option.&lt;BR /&gt;I would like to do following&lt;BR /&gt;script.sh -f file1.txt file2.txt -d dir1&lt;BR /&gt;But the script is failing.&lt;BR /&gt;If i do&lt;BR /&gt;script.sh -f "file1.txt file2.txt" -d dir1&lt;BR /&gt;then it is working fine.&lt;BR /&gt;I do not want to supply multiple argument in double quotes.&lt;BR /&gt;&lt;BR /&gt;2)What is the use of optind .&lt;BR /&gt;Can u pls explain with example."man getopts" is not very clear.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 04 Apr 2002 07:40:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696734#M56945</guid>
      <dc:creator>Aashish Raj</dc:creator>
      <dc:date>2002-04-04T07:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: getopts help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696735#M56946</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;each switch can only have one parameter, but you can use the same switch more the once:&lt;BR /&gt;&lt;BR /&gt;script.sh -f a b&lt;BR /&gt; is invalid&lt;BR /&gt;script.sh -f "a b"&lt;BR /&gt; is valid, your $OPTARG is "a b" and you may split it manually&lt;BR /&gt;script -f a -f b &lt;BR /&gt; is valid, you have to save your $OPTARG of the first "-f" , before you process the second "-f", because it will be redefined.&lt;BR /&gt;&lt;BR /&gt;The OPTIND is the index of your option valuein the commandline, beginning with 1 for the command itself:&lt;BR /&gt; eg.&lt;BR /&gt; script.sh -f a -f b&lt;BR /&gt;&lt;BR /&gt;OPTIND 1 2 3 4 5&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;Heiner</description>
      <pubDate>Thu, 04 Apr 2002 08:11:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696735#M56946</guid>
      <dc:creator>Heiner E. Lennackers</dc:creator>
      <dc:date>2002-04-04T08:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: getopts help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696736#M56947</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe this from the posix shell man is clearer&lt;BR /&gt;&lt;BR /&gt;getopts optstring name [arg]... &lt;BR /&gt;&lt;BR /&gt;  Parse the argument list, or the positional parameters if no arguments, for valid options. On each execution, return the next option in name. See getopts(1) for usage and description. &lt;BR /&gt;  &lt;BR /&gt;An option begins with a + or a -. An argument not beginning with + or -, or the argument --, ends the options. optstring contains the letters that getopts recognizes. If a letter is followed by a :, that option is expected to have an argument. The options can be separated from the argument by blanks. &lt;BR /&gt;  &lt;BR /&gt;For an option specified as -letter, name is set to letter. For an option specified as +letter, name is set to +letter. The index of the next arg is stored in OPTIND. The option argument, if any, is stored in OPTARG. If no option argument is found, or the option found does not take an argument, OPTARG is unset. &lt;BR /&gt;  &lt;BR /&gt;A leading : in optstring causes getopts to store the letter of an invalid option in OPTARG, and to set name to ? for an unknown option and to : when a required option argument is missing. Otherwise, getopts prints an error message. The exit status is nonzero when there are no more options. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;See&lt;BR /&gt;&lt;A href="http://unix.about.com/library/course/blshscript-l9h.htm" target="_blank"&gt;http://unix.about.com/library/course/blshscript-l9h.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;For a sample&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;              Steve Steel&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Apr 2002 08:15:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696736#M56947</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-04-04T08:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: getopts help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696737#M56948</link>
      <description>OPTIND is the index of the first argument after the options.&lt;BR /&gt;OPTARGS is the actual arguments pointed by OPTIND.&lt;BR /&gt;&lt;BR /&gt;Using getopts let you only assign arguments to flags using the "" or using ','; like:&lt;BR /&gt;-a "arg1 arg2" -b -c  OR&lt;BR /&gt;-a arg1,arg2 -b -c&lt;BR /&gt;&lt;BR /&gt;If you do not like this, i'm afraid you need to make your own program using argv,argc.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan&lt;BR /&gt;ps. If you find some other solution, please note your solution at the end of this call. It's interesting...</description>
      <pubDate>Thu, 04 Apr 2002 08:42:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-help/m-p/2696737#M56948</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-04-04T08:42:04Z</dc:date>
    </item>
  </channel>
</rss>

