![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using getopts | TurboArkhan | Shell Programming and Scripting | 3 | 06-22-2009 05:31 PM |
| getopts help | GrepMe | Shell Programming and Scripting | 3 | 06-20-2007 12:47 PM |
| help in getopts | problems | Shell Programming and Scripting | 1 | 05-05-2006 12:07 AM |
| getopts | yerra | Shell Programming and Scripting | 5 | 03-26-2005 10:43 AM |
| getopts | Shell Programming and Scripting | 3 | 12-05-2002 07:42 PM | |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help in getopts
Hi,
My script will take a input file as a parameter(which is not mandatory) and also an option. ksh my_script.sh <inputfile> [-n] The option -n I have given is no way related to the input file. Now the problem here is when i execute the script specifying the input file and the option(the way as mentioned above), the option part of the code is not working resulting me with no action. But when i execute the script in this way, I am getting my desired output ksh my_script.sh -n <inputfile> But this is not the way i should mention them. Why the option given at the end is not performing its action.? Is it a rule for getopts or problem with my code? Please help me regarding this. Sample code: #! /bin/ksh while getopts 'n' option do case "$option" in n)echo "option is n" ;; ?) echo " Bad option specified...." ;; esac done shift `expr $OPTIND - 1` INPUTFILE=$1 echo $INPUTFILE Thanks in advance, Chella |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|