http://goo.gl/EmKxy0

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.

usage:

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;;
   esac

done

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