![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| unix script to takes the old data from a TXT file and compress them into new file | vpandey | Shell Programming and Scripting | 2 | 03-05-2008 11:10 AM |
| To Write a Shell script that takes two arguments. | bobby36 | Shell Programming and Scripting | 3 | 04-05-2007 08:44 PM |
| shell script takes long time to complete | ozzman | Shell Programming and Scripting | 12 | 02-05-2007 11:25 PM |
| Write a script that takes 2 arguments | mopimp | UNIX for Dummies Questions & Answers | 6 | 03-24-2006 06:16 PM |
| evaluating params | abzi | UNIX for Dummies Questions & Answers | 3 | 11-22-2005 11:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
script takes params
i want to write a shell script that can be run as
./deployPortal.sh -version 5.1.2 -portlet -exportall how can i do that? version param is required. bu the others are optional. in first step i only want to read 5.1.2, is portlet selected ? and is exportall selected ?? can you help me?? |
|
|||||
|
Maybe use "getopts", "$*" or "$@", evaluate them with case or if...
Look for "positional parameters" in http://tldp.org/LDP/abs/html/othertypesv.html or http://tldp.org/LDP/abs/html/string-...l#GETOPTSIMPLE |
|
||||
|
Little example for you:
# Check for passed in arguments for i in $* do case "${i}" in -h*) help_output ;; -s1) valid_integer ${2} && integer DEF_SCREEN1_LOOP=${2} ;; -s2) valid_integer ${2} && integer DEF_SCREEN2_LOOP=${2} ;; -i) [[ -n ${2} ]] && DIRECTORY_USER_DEFAULT=${2} ;; -d) [[ -n ${2} ]] && DIRECTORY_SID_DEFAULT=${2} ;; -o) [[ -n ${2} ]] && OPWVDB_SID_DEFAULT=${2} ;; -t) if valid_integer ${2} then ((${2} > DEF_INTGAP)) && integer DEF_INTGAP=${2} fi ;; -c) if valid_integer ${2} then if ((${2} <= DEF_DBMIN_LOOP && ${2} != 0));then DEF_DBINT_LOOP=${DEF_DBMIN_LOOP} elif ((${2} > DEF_DBMIN_LOOP));then DEF_DBINT_LOOP=${2} fi fi ;; -u) DEF_COREUSER=${2} ;; -p) valid_integer ${2} && integer DEF_CORETTY=${2} ;; -nocore) DEF_CORECHECK=${NO} ;; *) ;; esac shift done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|