call shell script with named parameters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting call shell script with named parameters
# 1  
Old 11-12-2008
call shell script with named parameters

Could someone help me to call a shell script with named parameters.
I mean

Callscript .sh -c someconfigfile.txt
or
callscript.sh -config someconfigfile.txt

inside the script how can I retrieve someconfigfile.txt using the parametername -c or -config.

Thanks.
# 2  
Old 11-12-2008
You need to use getopts. Usually you can type man getopts to get some information, or search the web for examples.
# 3  
Old 11-12-2008
Thank you. I could retrieve the parameter value using the piece of code below.

while getopts c: option
do
case $option in
c)
Config_File=$OPTARG
;;
esac
done

echo $Config_File
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. Shell Programming and Scripting

How can I fetch few parameters in Shell script?

Hi All, I want to fetch few details out of a huge output of AWS CLI tools : I am using this command : ec2-describe-instances (6 Replies)
Discussion started by: Palak Sharma
6 Replies

3. Shell Programming and Scripting

How to call a bash script with positional parameters?

Hi, I have a script which will be executed using the below command, bin/nutch crawl urls -dir /data/test/ bin/nutch - Script file crawl, urls, /data/test/ - Parameters -dir - Option The above script should executed from a shell script named test.sh. I have the below code to execute... (2 Replies)
Discussion started by: vel4ever
2 Replies

4. Shell Programming and Scripting

Using Named pipe in shell script

Hi, I want to use a Named pipe to get input from a growing file for further processing. When I prototype this scenario using a while loop, the data is not written to the named pipe. This the script I use to get data into the Named pipe: #!/bin/ksh mkfifo pipe while (( n <= 10 )) do echo... (2 Replies)
Discussion started by: sudvishw
2 Replies

5. UNIX for Dummies Questions & Answers

shell script with parameters?

hi , I wanted to create a script, and I have no idea how to, and I would appreciate any help on that. Any advice on solving this is welcome. Thanks Here it goes: make a shell script in bash that show the activity of users. The results should be a summary or a complete report in a file.... (2 Replies)
Discussion started by: ubu-user
2 Replies

6. Shell Programming and Scripting

call another shell script and pass parameters to that shell script

Hi, I basically have 2 shell scripts. One is a shell script will get the variable value from the user. The variable is nothing but the IP of the remote system. Another shell script is a script that does the job of connecting to the remote system using ssh. This uses a expect utility in turn. ... (2 Replies)
Discussion started by: sunrexstar
2 Replies

7. Shell Programming and Scripting

call function with different parameters position

Hi I would like to call function in my script couple of times. But each time with different parameters position. In line 57 I don't know how to call it without typing $1 and $ parameters ? #!/bin/ksh 2 3 4 function First 5 { 6 7 # $1 - name 8 ... (2 Replies)
Discussion started by: presul
2 Replies

8. Shell Programming and Scripting

call a script from another script passing parameters

I want to call script2 from script1 passing parameters. I want to read the parameters list in script1, check the local directory (for example - lpath1|lpath2|lpath3|lpath4|lpath5|) for the existance of files and set the` lcount` to the number of files in this folder (`... (2 Replies)
Discussion started by: Lenora2009
2 Replies

9. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

10. UNIX for Dummies Questions & Answers

Call a UNIX shell with parameters from C

Hello...I hava quite a problem, couldn't find a solution anywhere :(. I have a C program, and from that C program I have to call a shell script. This is not difficult, I can do it using the "system" command from C. But the ugly part is how can I send as parameters some variables? For example...i... (1 Reply)
Discussion started by: dustman
1 Replies
Login or Register to Ask a Question