The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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 04:31 PM
Help in getopts chella Shell Programming and Scripting 4 11-02-2007 01:09 AM
help in getopts problems Shell Programming and Scripting 1 05-04-2006 11:07 PM
getopts yerra Shell Programming and Scripting 5 03-26-2005 10:43 AM
getopts google Shell Programming and Scripting 3 12-05-2002 07:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-20-2007
GrepMe GrepMe is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 11
getopts help

Hi

i have part of the scripts below ,getopt for -h or ? not working for me.
can anybody tell me if this sytax right or wrong.

#!/usr/bin/ksh
program=$(basename $0)
#####################################################################################
function usageerr
{
RC=1
USAGE="$program -s PROD_SCHEMA_NAME -d DEST_SCHEMA_NAME "
echo " usage:\n $USAGE "
exit $RC
}
######################################################################################
while getopts s:d:h arguments
do
case $arguments in
s|S) SRCE_SCHEMA_NAME=$OPTARG;;
d|D) DEST_SCHEMA_NAME=$OPTARG ;;
h|H|?) usageerr ;;
*) echo " $program :$OPTARG requires a value." ;;
esac
done
shift $(($OPTIND -1))
if [[ $# -le 1 ]]
then
echo " Incorrect number of arguments "
usageerr
fi

Thanks u

Last edited by GrepMe; 06-20-2007 at 08:50 AM..
  #2 (permalink)  
Old 06-20-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Grepme,
You cannot use question mark "?" -- nor colon ":" -- as option characters.
  #3 (permalink)  
Old 06-20-2007
GrepMe GrepMe is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 11
? seen on man getopts

Hi thanks for your reply Sir,

I have checked the man it says you can use the ? mark .


Thanks
  #4 (permalink)  
Old 06-20-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
From man page of "getopts" on SunOS:
Quote:
The characters question-mark "?" and colon ":" must not be used
as option characters by an application.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0