<?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: Passing parameters to script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492567#M704686</link>
    <description>Hi Pat,&lt;BR /&gt;I don't know what exactly you are looking for but with the given info i would do it this way using korne shell:&lt;BR /&gt;&lt;BR /&gt;script.sh&lt;BR /&gt;---------&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;list=$*&lt;BR /&gt;for i in $list&lt;BR /&gt;do&lt;BR /&gt;if [ "$1" -eq "-u" ]&lt;BR /&gt;then &lt;BR /&gt;   echo $2 $3 ...&lt;BR /&gt;elif [ "$1" -eq "-h" ]&lt;BR /&gt;then&lt;BR /&gt;   echo $2 $3 ...&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This you can keep on putting if-then-fi as reuired or you can even use CASE statements.&lt;BR /&gt;&lt;BR /&gt;See man sh for more information.&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
    <pubDate>Thu, 24 Feb 2005 06:04:28 GMT</pubDate>
    <dc:creator>Bharat Katkar</dc:creator>
    <dc:date>2005-02-24T06:04:28Z</dc:date>
    <item>
      <title>Passing parameters to script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492566#M704685</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am writing a script in which I have to pass some command line arguments to the script.&lt;BR /&gt;&lt;BR /&gt;For instance, my script's name is script.sh and it should have the following usage&lt;BR /&gt;&lt;BR /&gt;script.sh -h &lt;NAME&gt; -d date -v version.&lt;BR /&gt;&lt;BR /&gt;ALso I should probably give a usage for the script where &lt;BR /&gt;&lt;BR /&gt;script.sh -u &lt;BR /&gt;&lt;BR /&gt;will give me the usage of all the parameters. &lt;BR /&gt;&lt;BR /&gt;I have not done this before.&lt;BR /&gt;&lt;BR /&gt;Can anyone please send me a sample code which has this kind of functionality.&lt;BR /&gt;&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat&lt;/NAME&gt;</description>
      <pubDate>Thu, 24 Feb 2005 05:54:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492566#M704685</guid>
      <dc:creator>Pat Peter</dc:creator>
      <dc:date>2005-02-24T05:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492567#M704686</link>
      <description>Hi Pat,&lt;BR /&gt;I don't know what exactly you are looking for but with the given info i would do it this way using korne shell:&lt;BR /&gt;&lt;BR /&gt;script.sh&lt;BR /&gt;---------&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;list=$*&lt;BR /&gt;for i in $list&lt;BR /&gt;do&lt;BR /&gt;if [ "$1" -eq "-u" ]&lt;BR /&gt;then &lt;BR /&gt;   echo $2 $3 ...&lt;BR /&gt;elif [ "$1" -eq "-h" ]&lt;BR /&gt;then&lt;BR /&gt;   echo $2 $3 ...&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This you can keep on putting if-then-fi as reuired or you can even use CASE statements.&lt;BR /&gt;&lt;BR /&gt;See man sh for more information.&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 06:04:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492567#M704686</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-02-24T06:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492568#M704687</link>
      <description>Pat,&lt;BR /&gt;if you have perl:&lt;BR /&gt;&lt;BR /&gt;cat a.pl&lt;BR /&gt;#!/usr/contrib/bin/perl -s&lt;BR /&gt;print "value of -h: $h\n";&lt;BR /&gt;print "value of -d: $d\n";&lt;BR /&gt;print "value of -v: $v\n";&lt;BR /&gt;&lt;BR /&gt;./a.pl -h=peter -d=20050224 -v=1.0&lt;BR /&gt;value of -h: peter&lt;BR /&gt;value of -d: 20050224&lt;BR /&gt;value of -v: 1.0&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 06:37:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492568#M704687</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2005-02-24T06:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492569#M704688</link>
      <description>Read getopt(1) and getopts(1) manual pages for details of parsing command line.&lt;BR /&gt;&lt;BR /&gt;Here there is an example:&lt;BR /&gt;&lt;BR /&gt;FILENAME=""&lt;BR /&gt;VERBOSE=0&lt;BR /&gt;OPTIONS=ahF:V&lt;BR /&gt;&lt;BR /&gt;while getopts "${OPTIONS}" OPTION 2&amp;gt; /dev/null&lt;BR /&gt;do&lt;BR /&gt;    case ${OPTION} in&lt;BR /&gt;     (a) echo "option 'a' selected"&lt;BR /&gt;         ;;&lt;BR /&gt;     (F) FILENAME="${OPTARG}"&lt;BR /&gt;         ;;&lt;BR /&gt;     (v) VERBOSE=1&lt;BR /&gt;         ;;&lt;BR /&gt;     (h) print  "usage: $(basename $0) [-a] [-v] [-F type]"&lt;BR /&gt;         print  "usage: $(basename $0) -h"&lt;BR /&gt;         exit&lt;BR /&gt;         ;;&lt;BR /&gt;    (\?) print -u2 "usage: $(basename $0) [-a] [-v] [-F type]"&lt;BR /&gt;         print -u2 "usage: $(basename $0) -h"&lt;BR /&gt;         exit 1&lt;BR /&gt;         ;;&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;shift $(( ${OPTIND} - 1 ))&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 06:52:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492569#M704688</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2005-02-24T06:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492570#M704689</link>
      <description>you would do something like this:&lt;BR /&gt;&lt;BR /&gt;program="${0:##*/}"&lt;BR /&gt;&lt;BR /&gt;function usage {&lt;BR /&gt;print -u2 "$program [-d date -h name -v version | -u]"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while getopts :d:h:v:u OPTION&lt;BR /&gt;do&lt;BR /&gt;        case "$OPTION" in&lt;BR /&gt;        d) Date="$OPTARG";;&lt;BR /&gt;        h) Name="$OPTARG";;&lt;BR /&gt;        v) Version="$OPTARG";;;;&lt;BR /&gt;        u) usage;exit;;&lt;BR /&gt;        :) print -u2 "$program: $OPTARG is missing argument!"&lt;BR /&gt;           usage&lt;BR /&gt;           exit 1;;&lt;BR /&gt;        \?) print -u2 "$program: $OPTARG is an invalid option!"&lt;BR /&gt;            usage&lt;BR /&gt;            exit 1;;&lt;BR /&gt;        esac&lt;BR /&gt;done&lt;BR /&gt;shift $(( $OPTIND - 1 ))&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Feb 2005 09:27:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-parameters-to-script/m-p/3492570#M704689</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2005-02-24T09:27:00Z</dc:date>
    </item>
  </channel>
</rss>

