Passing a parameter while calling a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing a parameter while calling a script
# 1  
Old 02-12-2008
Passing a parameter while calling a script

Hello everyone

I was asked to pass a parameter in the calling of a script. IŽll have two parameters London and Birmingham and IŽll need to pass this because each of these will have a specific script however with the same name.

/home/script/loaddata.ksh Lond

/home/script/loaddata.ksh Birm

My question is how can I do it, and how can I configure the scripts?

Best Regards & Best luck for all

Rafael Buria
# 2  
Old 02-12-2008
I'm not sure what you mean, but when you want to compare the parameter passed in the script you should compare the $1 in the script (think this is very basic)..
so if this is what you want, you should do something like this:

if [ $1 == 'Lond' ]
then
... do something in London ...
else if [ $1 == 'Birm' ]
then
... something in Birmingham ....
fi
fi

But I think I misunderstood the question, so please explain a bit more.
# 3  
Old 02-13-2008
Hello Sir and thanks for the answer... ItŽs a little bit hard to explain what I want in this....

I need to make the call of some script and pass a parameter like a sad I have two of them Lond and Birm....I really do not know how to make this "call" of my script passing the parameter and I do not know how the script will understand that when I pass Lond it will run the script for London. The comparison I think that will be made inside the script but I donŽt know if IŽll have to use an auxiliar script to check the call....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing shell script parameter value to awk command in side the script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies

2. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

3. AIX

Passing a parameter to a shell script?

I would like to run a compress script on files in certain directories. My compress_script.sh is just basically compress file* In order for me to use this I have to copy it into each directory and run it. How can I state the directory on the command line with the compress script so it... (2 Replies)
Discussion started by: NycUnxer
2 Replies

4. Shell Programming and Scripting

Issue in passing a parameter value from one script to another

Hi Experts, I am passing current month & day (i.e. 'Jul 21') from script aaa.ksh to zzz.ksh. The value 'Mon DD' is being used in zzz.ksh. Problem: If I pass 'Mon DD' value manually to zzz.ksh i.e. /test/zzz.ksh 'Jul 21' it works fine. However, if I pass value from aaa.ksh, it does... (2 Replies)
Discussion started by: dipeshvshah
2 Replies

5. Shell Programming and Scripting

passing a variables value from the called script to calling script using ksh

How do i get the value of the variable from the called script(script2) to the calling script(script1) in ksh ? I've given portion of the script here to explain the problem. Portion of Script 1 ============= ----- ----- tmp=`a.ksh p1 p2 p3` if then # error processing fi -----... (10 Replies)
Discussion started by: rajarkumar
10 Replies

6. Shell Programming and Scripting

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

7. Shell Programming and Scripting

Passing Filename as a Parameter to Another script

Hi, I have a requirement to write a script file(script1.sh) to read the file from the folder say /usr1/profiles/active and pass the file name as a parameter to another script file say (script2.sh) which would subsitute this parameter. The script2.sh will have a line like the one below ... (1 Reply)
Discussion started by: ravisg
1 Replies

8. UNIX for Advanced & Expert Users

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

9. Shell Programming and Scripting

Passing exit code to calling script

In production I need to pass an exit code from a script that is being called 3 or 4 layers deep. I've created test scripts to play with it until I get it right. As you can tell, this is not my normal job. Perhaps I should have entered this in UNIX for Dummies section. Anyway, I keep losing the... (2 Replies)
Discussion started by: debbiekuch
2 Replies

10. Shell Programming and Scripting

Passing Date as parameter with sh script

Hi I need to pass a date argument with my shell script. Can any one send me code for the same. eg For 15th Aug 2006. Iwant to pass parameter like this ./startenv.sh 08/15/2006. Everyday date argument must change. Will the below code work ? ./startenv.sh date '+%m/%d/%y' THanks... (1 Reply)
Discussion started by: pankajkrmishra
1 Replies
Login or Register to Ask a Question