Sponsored Content
Top Forums Shell Programming and Scripting getopts takes options for parameters Post 99501 by tmarikle on Friday 17th of February 2006 07:32:35 PM
Old 02-17-2006
I add another case statement for these kinds of parameters:
Code:
#!/bin/ksh

USAGE=$([-a] [-b file_b] [-c] [-d] [-e file_e] [-f]);
while getopts "ab:cde:f" opt
do
    case ${opt} in
        b|e)
            [[ ${OPTARG} = -* ]]   && usage "Invalid parameter \"${OPTARG}\" provided for agurment \"-${opt}!\""
            [[ ${#OPTARG} -eq 0 ]] && usage "Argument \"-${opt}\" requires a parameter!${OPTARG}"
        ;;
    esac

    case $opt in
        a) minusa=$opt;;
        b) minusb=$opt
        file_b=$OPTARG;;
        c) minusc=$opt;;
        d) minusd=$opt;;
        e) minuse=$opt
        file_e=$OPTARG;;
        f) minusf=$opt''
        /?) echo Unrecognized parameter
        exit 1;;
    esac

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get Options and Parameters

Hi there. Could someone explain how do i get the options separated from the arguments. My problem is that i have a lot of options and in all of those options i need to have the parameters available to use in that option and all the others. How can i take the arguments before i cycle throw the... (4 Replies)
Discussion started by: KitFisto
4 Replies

2. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

3. Programming

Parse parameters with getopts

Hi, this is my problem I have script with two parameters -n name and -s surname. Both have arguments and I want to know how parse these parameters with getopts. When you write ./names -n John -s White it find you all persons, which name is John White, but when you write ./names -n John ... (1 Reply)
Discussion started by: frees
1 Replies

4. Shell Programming and Scripting

Intersperse arguments and options w/ getopts

Is it possible to get a script that uses getopts to accept options and arguments in any order? eg. -g -h 2 4 works like -g 2 -h 4. (1 Reply)
Discussion started by: lee.n.doan
1 Replies

5. Shell Programming and Scripting

Order of getopts parameters

Hi, Does the order of argument and non-argument command line parameters matter to getopts? with a getopts line in my script of getopts p:cs opt a command line of <script> -p 5 -s only picks up the -p option, while <script> -s -p 5 picks up both. Removing the space between the p and the... (3 Replies)
Discussion started by: rojomoke
3 Replies

6. Shell Programming and Scripting

ksh processing options and parameters

I have a requirement where I need to process both options and parameters. command line call ie xxx.ksh -sid TEST1 -search_str LOCKED user1 user2 ..... I am using the following peice of code but I am usure how I can loop through all my parameters user1, user2, ... Note at the minium... (2 Replies)
Discussion started by: BeefStu
2 Replies

7. Shell Programming and Scripting

Using getopts for handling multiple options

Hi Guys, I have created a script for our automated DB creation, it works fine with default option(-d). $ ./test_db.ksh -d abc 11 dev -d is Default option ORACLE_SID=abc ORACLE_VERSION=11 ENV_TYPE=dev For creating a customized DB, i thought of giving the user different options.... (8 Replies)
Discussion started by: veeresh_15
8 Replies

8. Shell Programming and Scripting

Getopts with optional parameters

Hi Unix Gurus, i am on learning path of unix, and yet to discover many things. I came across with this requirement where i need to pass parameters but the position of parameters is not fixed so after doing some google search got to know "getopts" can handle that. So here is my code: function... (3 Replies)
Discussion started by: gnnsprapa
3 Replies
TIDY_GET_OPT_DOC(3)							 1						       TIDY_GET_OPT_DOC(3)

tidy::getOptDoc - Returns the documentation for the given option name

       Object oriented style

SYNOPSIS
string tidy::getOptDoc (string $optname) DESCRIPTION
Procedural style string tidy_get_opt_doc (tidy $object, string $optname) tidy_get_opt_doc(3) returns the documentation for the given option name. Note You need at least libtidy from 25 April, 2005 for this function be available. PARAMETERS
o $object - The Tidy object. o $optname - The option name RETURN VALUES
Returns a string if the option exists and has documentation available, or FALSE otherwise. EXAMPLES
Example #1 Print all options along with their documentation and default value <?php $tidy = new tidy; $config = $tidy->getConfig(); ksort($config); foreach ($config as $opt => $val) { if (!$doc = $tidy->getOptDoc($opt)) $doc = 'no documentation available!'; $val = ($tidy->getOpt($opt) === true) ? 'true' : $val; $val = ($tidy->getOpt($opt) === false) ? 'false' : $val; echo "<p><b>$opt</b> (default: '$val')<br />". "$doc</p><hr /> "; } ?> SEE ALSO
tidy.getconfig(3), tidy.getopt(3). PHP Documentation Group TIDY_GET_OPT_DOC(3)
All times are GMT -4. The time now is 06:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy