<?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 implement option in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778412#M640844</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am writing the following script to check the file owner permission whether Write bit is enabled or not.  The problem with this script is I still have problem to get it work with directory.&lt;BR /&gt;&lt;BR /&gt;if the input is a directory i need to check whether those files in the directory has any file with write permission enabled, if so I will skip the files but will continue to copy over the rest of the files that meet requirement to the target together with directory and their associate subdirectory.&lt;BR /&gt;&lt;BR /&gt;Also I was thought to implement -s and -t in the script so that I do not need to worry about the TGT variable which is the target filesystem.</description>
    <pubDate>Mon, 18 Apr 2011 01:12:29 GMT</pubDate>
    <dc:creator>kholikt</dc:creator>
    <dc:date>2011-04-18T01:12:29Z</dc:date>
    <item>
      <title>implement option in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778412#M640844</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am writing the following script to check the file owner permission whether Write bit is enabled or not.  The problem with this script is I still have problem to get it work with directory.&lt;BR /&gt;&lt;BR /&gt;if the input is a directory i need to check whether those files in the directory has any file with write permission enabled, if so I will skip the files but will continue to copy over the rest of the files that meet requirement to the target together with directory and their associate subdirectory.&lt;BR /&gt;&lt;BR /&gt;Also I was thought to implement -s and -t in the script so that I do not need to worry about the TGT variable which is the target filesystem.</description>
      <pubDate>Mon, 18 Apr 2011 01:12:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778412#M640844</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2011-04-18T01:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: implement option in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778413#M640845</link>
      <description>I have tried the following:&lt;BR /&gt;&lt;BR /&gt;while [ $# -gt 0 ]&lt;BR /&gt;do&lt;BR /&gt;    case "$1" in&lt;BR /&gt;        -s) src=$2;;&lt;BR /&gt; -t) tgt=$2;;&lt;BR /&gt;  *) break;; &lt;BR /&gt;    esac&lt;BR /&gt;    shift&lt;BR /&gt;done&lt;BR /&gt;echo "cp -pr $src $tgt"&lt;BR /&gt;&lt;BR /&gt;but it cannot process -s -t together and will extend after the -s</description>
      <pubDate>Mon, 18 Apr 2011 02:34:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778413#M640845</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2011-04-18T02:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: implement option in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778414#M640846</link>
      <description>I also tried the getopts but doesn't be able to use case st&lt;BR /&gt;&lt;BR /&gt;while getopts s:t option&lt;BR /&gt;do&lt;BR /&gt;    case "${option}" &lt;BR /&gt;    in&lt;BR /&gt;        s) src=${OPTARG};;&lt;BR /&gt; t) tgt=${OPTARG};;&lt;BR /&gt; *) break;; &lt;BR /&gt;    esac&lt;BR /&gt;    shift&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo "$src $tgt"</description>
      <pubDate>Mon, 18 Apr 2011 02:55:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778414#M640846</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2011-04-18T02:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: implement option in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778415#M640847</link>
      <description>&lt;!--!*#--&gt;In your first example, when your option needs an argument, you must remember to shift both the option and its argument to successfully parse the options:&lt;BR /&gt;&lt;BR /&gt;--------&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;while [ $# -gt 0 ]&lt;BR /&gt;do&lt;BR /&gt;    case "$1" in&lt;BR /&gt;        -s)&lt;BR /&gt;                src="$2"&lt;BR /&gt;                shift #An extra shift here...&lt;BR /&gt;                ;;&lt;BR /&gt;        -t)&lt;BR /&gt;                tgt="$2"&lt;BR /&gt;                shift #...and here&lt;BR /&gt;                ;;&lt;BR /&gt;        *)&lt;BR /&gt;                break&lt;BR /&gt;                ;;&lt;BR /&gt;    esac&lt;BR /&gt;    shift&lt;BR /&gt;done&lt;BR /&gt;echo "cp -pr $src $tgt"&lt;BR /&gt;--------&lt;BR /&gt;&lt;BR /&gt;With getopts, you should indicate that both your options have arguments, so the correct optstring is "s:t:", not "s:t". When you're using getopts to parse options, don't use the "shift" command in the same loop.&lt;BR /&gt;-------&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;while getopts s:t: option&lt;BR /&gt;do&lt;BR /&gt;    case "${option}" in&lt;BR /&gt;        s) &lt;BR /&gt;                src="${OPTARG}"&lt;BR /&gt;                ;;&lt;BR /&gt;        t) &lt;BR /&gt;                tgt="${OPTARG}"&lt;BR /&gt;                ;;&lt;BR /&gt;        *) &lt;BR /&gt;                break&lt;BR /&gt;                ;;&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo "$src $tgt"&lt;BR /&gt;-------&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Mon, 18 Apr 2011 03:23:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778415#M640847</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-04-18T03:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: implement option in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778416#M640848</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;In my opinion, using 'getopts' as soon as you have more than one option and/or argument is the appropriate course.&lt;BR /&gt;&lt;BR /&gt;Useful programs tend to sprout more useful features.  Having begun with getopts() to handle options and arguments offers an easy-to-amend framework.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 18 Apr 2011 11:07:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778416#M640848</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-18T11:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: implement option in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778417#M640849</link>
      <description>&lt;P&gt;HI (again):&lt;BR /&gt;&lt;BR /&gt;You have a growing number of questions with unassigned points. Only about 3-of-10 of the responses you have received have been scored:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please take a few minutes to show us what helped you and to say "thanks".&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2011 20:18:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/implement-option-in-script/m-p/4778417#M640849</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-08-02T20:18:53Z</dc:date>
    </item>
  </channel>
</rss>

