script takes params


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script takes params
# 1  
Old 06-06-2008
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  
Old 06-06-2008
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  
Old 06-06-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script takes too long to complete

Hi, I have a lengthy script which i have trimmed down for a test case as below. more run.sh #!/bin/bash paths="allpath.txt" while IFS= read -r loc do echo "Working on $loc" startdir=$loc find "$startdir" -type f \( ! -name "*.log*" ! -name "*.class*" \) -print | while read file do... (8 Replies)
Discussion started by: mohtashims
8 Replies

2. Shell Programming and Scripting

Script that takes IP address as an Input and deletes 7 lines

I have a flat file that contains a list of IP address following 6 additional lines. I would like to get a help in the following. a shell script that would take ip address or list of ip addresses as input, search one by one the ip address in the file and as soon as it find the exact match it... (12 Replies)
Discussion started by: knijjar
12 Replies

3. Shell Programming and Scripting

How to kill a child script if it takes more than 10 minutes?

Hi all, I have a query on killing a child process, if it takes more than 10 minutes myparent.sh has the following #!/bin/sh echo "My Parent Script" home/guru/initiateServer.sh The initiateServer is a child process and this might take 20 or more minutes to return. I want to kill this... (11 Replies)
Discussion started by: guruincredible
11 Replies

4. Shell Programming and Scripting

Script that takes strings as input

Hello all! I need to take a series of inputs passed to one shell script and pass them to a second shell script. For example, the first shell script, script_one.sh, has the following inputs: ./script_one -u username -p password -option1 string1 -option2 -string2 ....Inside of script_one.sh... (4 Replies)
Discussion started by: bashnewbee
4 Replies

5. UNIX for Dummies Questions & Answers

script takes the whole filename instead of just extension

I am running my script from "/abc/" this path and it has no ".csv files" but has a ".txt" files namely temp1.txt My script goes as below, wherein it is suppose to find files with *.txt extension and *.csv extension in another path namely "/abc/xyz/": #!/bin/ksh PATH1="/abc/xyz/" value="*.csv... (1 Reply)
Discussion started by: wolverine999
1 Replies

6. Shell Programming and Scripting

Script that takes in variables, and outputs to another text or script file

Ok, I sort of need to create a command files that will be ftped to another server to run. I have some input variable that will need to be read, and then transformed into another script file. Here are some examples. Server 1: outputCmd.sh passing in ./outputCmd.sh nh8oaxt Release_4_0... (1 Reply)
Discussion started by: orozcom
1 Replies

7. Shell Programming and Scripting

need inputs on how i can change my script to reduce amount of time the script takes

HI , I have a list1 which consists of data that i have to search and a list2 which has the files that need to be searched .So basically i am using list1 on list2 to see if list1 data is present if found replace it .I have written the code using foreach loop for each list .This is taking the... (1 Reply)
Discussion started by: madhul2002
1 Replies

8. Shell Programming and Scripting

To Write a Shell script that takes two arguments.

How to write a shell script tht takes two arguments.The first being a line of text,the second being your newly created file(x no:of lines and content of ur choice). The script should take the first argument and insert it into the very top(the first line)of the file named in your second argument.... (3 Replies)
Discussion started by: bobby36
3 Replies

9. Shell Programming and Scripting

shell script takes long time to complete

Hi all, I wrote this shell script to validate filed numbers for input file. But it take forever to complete validation on a file. The average speed is like 9mins/MB. Can anyone tell me how to improve the performance of a shell script? Thanks (12 Replies)
Discussion started by: ozzman
12 Replies

10. UNIX for Dummies Questions & Answers

Write a script that takes 2 arguments

hi i would be grateful for some help on the following q. "Write a script that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top ( the first line) of the file named in your... (6 Replies)
Discussion started by: mopimp
6 Replies
Login or Register to Ask a Question