Sponsored Content
Top Forums Shell Programming and Scripting Position independent Parameter passing Post 302135462 by sonaluphale on Monday 10th of September 2007 02:34:20 AM
Old 09-10-2007
Position independent Parameter passing

Hi all,
When parameters are passed to the shell script, they are dereferenced by their position. For example,
I call myTest.sh and pass two parameters param1 and param2 as following:
./myTest.sh param1 param2

In the script, myTest.sh, I refer to first parameter (param1 ) as $1 and second parameter (param2) as $2.

Is there any way to make parameter passing independent. Something like
./myTest.sh -Dparameter1=param1 -Dparameter2=param2


Thanks,
Sonal.
 

10 More Discussions You Might Find Interesting

1. HP-UX

fd passing between Independent processes using unix domain sockets

Hi, I am having some error handling issues with and fd passed between Independent processes using unix domain sockets (On HPUX). Here is the scnerio ================= Step 1: TPC/Client (connect()) ---Connects to ------TCP/Server(Gateway) (server gets fd) Step 2: ... (2 Replies)
Discussion started by: Debasisb2002
2 Replies

2. Shell Programming and Scripting

parameter passing

Hallo everyone, This is my problem below: /home/cerebrus/pax=>vat class2.sh ksh: vat: not found /home/cerebrus/pax=>cat class2.sh #!/bin/ksh set -x bdf|grep appsdev|awk '{ print $5 }'> class3 dd={cat class3} echo $dd /home/cerebrus/pax=> /home/cerebrus/pax=>./class2.sh + bdf +... (8 Replies)
Discussion started by: kekanap
8 Replies

3. UNIX for Advanced & Expert Users

Parameter passing in a function

I need to pass a parameter to a function in a script. My parameter is a string. When I display the parameter within my function, I only get the first word from string I pass in. How can I make the function receive the whole string (and not terminate at the first space it encounters)?. part of... (2 Replies)
Discussion started by: fastgoon
2 Replies

4. Shell Programming and Scripting

wrong parameter passing!

Hi all I have a script which will take input as filename and passes it to a java program. It is as follows -------------------------------- FILENAME=$1 echo $FILENAME ${JAVA_HOME}/bin/java -cp DateProvider $FILENAME ------------------------------------------------- when I execute the same... (2 Replies)
Discussion started by: malle
2 Replies

5. Programming

passing float parameter

I am surprised by GCC (this is ver. 4.2.4, Ubuntu 32 bit Intel) when a function declares a float parameter and it's prototype is missing, the parameters are messed up. Please see my code below: ~/test$ cat x1.c #include <stdio.h> #include <stdlib.h> set_p(int p1, float p2, int p3, int p4)... (7 Replies)
Discussion started by: migurus
7 Replies

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

7. Shell Programming and Scripting

How to use this position parameter?

Hi Gurus, I want split one huge line file to multiple line, I got code from you guys yesterday. I want put the code in a script which use two position parameter when run the script. my code like: awk '{for (i=1; i<=length($0); i+=$2) print substr($0, i, $2)}' $1 > $1_split when I run the... (6 Replies)
Discussion started by: ken6503
6 Replies

8. Shell Programming and Scripting

Passing parameter more than 9

Hi, I've written a script where eleven parameter to be passed from command line which is inserting into an oracle table, it is working but the tenth and 11th parameter are not accepting as given it is referring to 1st parameter. HERE IS THE SCRIPT #!/bin/ksh #set -o echo $*... (4 Replies)
Discussion started by: sankar
4 Replies

9. Shell Programming and Scripting

Passing parameter through file

Hi , I am passing date parameter through file my shell script testing.sh is #set -x #set -v asd=$1 asd1=$2 echo $asd echo $asd1 Passing parameter as below sh testing.sh `cat file1.txt` Output (2 Replies)
Discussion started by: kaushik02018
2 Replies

10. Shell Programming and Scripting

How to pass position parameter into function.?

Hi Gurus, I have request which needs to pass position parameter to a function. I tried below simple code, it doesn't work. #!/bin/bash func_1(){ echo $1 } func_1 $ ./set_file abc $ do I need add some to get the position para first? thanks in advance. (3 Replies)
Discussion started by: ken6503
3 Replies
Dancer::ModuleLoader(3pm)				User Contributed Perl Documentation				 Dancer::ModuleLoader(3pm)

NAME
Dancer::ModuleLoader - dynamic module loading helpers for Dancer core components SYNOPSIS
Taken directly from Dancer::Template::TemplateToolkit (which is core): die "Template is needed by Dancer::Template::TemplateToolkit" unless Dancer::ModuleLoader->load('Template'); # we now have Template loaded DESCRIPTION
Sometimes in Dancer core we need to use modules, but we don't want to declare them all in advance in compile-time. These could be because the specific modules provide extra features which depend on code that isn't (and shouldn't) be in core, or perhaps because we only want these components loaded in lazy style, saving loading time a bit. For example, why load Template (which isn't required by Dancer) when you don't use Dancer::Template::TemplateToolkit? To do such things takes a bit of code for localizing $@ and "eval"ing. That code has been refactored into this module to help Dancer core developers. Please only use this for Dancer core modules. If you're writing an external Dancer module (Dancer::Template::Tiny, Dancer::Session::Cookie, etc.), please simply ""use ModuleYouNeed"" in your code and don't use this module. METHODS
/SUBROUTINES load Runs a ""use ModuleYouNeed"". use Dancer::ModuleLoader; ... Dancer::ModuleLoader->load('Something') or die "Couldn't load Something "; # load version 5.0 or more Dancer::ModuleLoader->load('Something', '5.0') or die "Couldn't load Something "; # load version 5.0 or more my ($res, $error) = Dancer::ModuleLoader->load('Something', '5.0'); $res or die "Couldn't load Something : '$error' "; Takes in arguments the module name, and optionally the minimum version number required. In scalar context, returns 1 if successful, 0 if not. In list context, returns 1 if successful, "(0, "error message")" if not. If you need to give argumentto the loading module, please use the method "load_with_params" require Runs a ""require ModuleYouNeed"". use Dancer::ModuleLoader; ... Dancer::ModuleLoader->require('Something') or die "Couldn't require Something "; my ($res, $error) = Dancer::ModuleLoader->require('Something'); $res or die "Couldn't require Something : '$error' "; If you are unsure what you need ("require" or "load"), learn the differences between "require" and "use". Takes in arguments the module name. In scalar context, returns 1 if successful, 0 if not. In list context, returns 1 if successful, "(0, "error message")" if not. load_with_params Runs a ""use ModuleYouNeed qw(param1 param2 ...)"". use Dancer::ModuleLoader; ... Dancer::ModuleLoader->load('Something', qw(param1 param2) ) or die "Couldn't load Something "; my ($res, $error) = Dancer::ModuleLoader->load('Something', @params); $res or die "Couldn't load Something : '$error' "; Takes in arguments the module name, and optionally parameters to pass to the import internal method. In scalar context, returns 1 if successful, 0 if not. In list context, returns 1 if successful, "(0, "error message")" if not. use_lib Runs a ""use lib qw(path1 path2)"" at run time instead of compile time. use Dancer::ModuleLoader; ... Dancer::ModuleLoader->use_lib('path1', @other_paths) or die "Couldn't perform use lib "; my ($res, $error) = Dancer::ModuleLoader->use_lib('path1', @other_paths); $res or die "Couldn't perform use lib : '$error' "; Takes in arguments a list of path to be prepended to @INC, in a similar way than "use lib". However, this is performed at run time, so the list of paths can be generated and dynamic. In scalar context, returns 1 if successful, 0 if not. In list context, returns 1 if successful, "(0, "error message")" if not. class_from_setting Given a setting in Dancer::Config, composes the class it should be. This is the function that translates: # in config.yaml template: "template_toolkit" To the class: Dancer::Template::TemplateToolkit Example: use Dancer::ModuleLoader; my $class = Dancer::ModuleLoader->class_from_setting( 'Dancer::Template' => 'template_toolkit', ); # $class == 'Dancer::Template::TemplateToolkit $class = Dancer::ModuleLoader->class_from_setting( 'Dancer::Template' => 'tiny', ); # class == 'Dancer::Template::Tiny AUTHOR
Alexis Sukrieh LICENSE AND COPYRIGHT
Copyright 2009-2010 Alexis Sukrieh. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. perl v5.14.2 2011-11-26 Dancer::ModuleLoader(3pm)
All times are GMT -4. The time now is 08:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy