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

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-06-2008
keromotti keromotti is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 1
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??
  #2 (permalink)  
Old 06-06-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
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
  #3 (permalink)  
Old 06-06-2008
jm0221 jm0221 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
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
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 02:03 AM.


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