Home > ASE, Developement, Start Sybase, UNIX > getopts unix command

getopts unix command

getopts is an unix command to fetch argument and argument values. OPTARG and OPTIND are two variables to hold argument values and index.


suppose we have define command usage as below

test.ksh [-s <server name>] [-d <database name>] [-u <user name>] [-p <password>]

so usage is

while getopts s:S:d:D:u:U:p:P i

do case “$i” in

        s|S) SERVER="$OPTARG";;
        d|D) DATABASE="$OPTARG";;
        u|U) USER="$OPTARG";;
        p|P) PASS="$OPTARG";;
        ?) usage;;


Check the Sybase Wiki @
Categories: ASE, Developement, Start Sybase, UNIX Tags: ,
  1. No comments yet.
  1. No trackbacks yet.