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
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT DEBIAN
class::adapter::builder
Class::Adapter::Builder(3pm) User Contributed Perl Documentation Class::Adapter::Builder(3pm)
NAME
Class::Adapter::Builder - Generate Class::Adapter classes
SYNOPSIS
package My::Adapter;
use strict;
use Class::Adapter::Builder
ISA => 'Specific::API',
METHODS => [ qw{foo bar baz} ],
method => 'different_method';
1;
DESCRIPTION
"Class::Adapter::Builder" is another mechanism for letting you create Adapter classes of your own.
It is intended to act as a toolkit for generating the guts of many varied and different types of Adapter classes.
For a simple base class you can inherit from and change a specific method, see Class::Adapter::Clear.
The Pragma Interface
The most common method for defining Adapter classes, as shown in the synopsis, is the pragma interface.
This consists of a set of key/value pairs provided when you load the module.
# The format for building Adapter classes
use Class::Adapter::Builder PARAM => VALUE, ...
ISA The "ISA" param is provided as either a single value, or a reference to an "ARRAY" containing is list of classes.
Normally this is just a straight list of classes. However, if the value for "ISA" is set to '_OBJECT_' the object will identify itself
as whatever is contained in it when the "->isa" and "->can" method are called on it.
NEW Normally, you need to create your "Class::Adapter" objects separately:
# Create the object
my $query = CGI->new( 'param1', 'param2' );
# Create the Decorator
my $object = My::Adapter->new( $query );
If you provide a class name as the "NEW" param, the Decorator will do this for you, passing on any constructor arguments.
# Assume we provided the following
# NEW => 'CGI',
# We can now do the above in one step
my $object = My::Adapter->new( 'param1', 'param2' );
AUTOLOAD
By default, a "Class::Adapter" does not pass on any methods, with the methods to be passed on specified explicitly with the 'METHODS'
param.
By setting "AUTOLOAD" to true, the "Adapter" will be given the standard "AUTOLOAD" function to to pass through all unspecified methods
to the parent object.
By default the AUTOLOAD will pass through any and all calls, including calls to private methods.
If the AUTOLOAD is specifically set to 'PUBLIC', the AUTOLOAD setting will ONLY apply to public methods, and any private methods will
not be passed through.
METHODS
The "METHODS" param is provided as a reference to an array of all the methods that are to be passed through to the parent object as is.
Any params other than the ones specified above are taken as translated methods.
# If you provide the following
# foo => bar
# It the following are equivalent
$decorator->foo;
$decorator->_OBJECT_->bar;
This capability is provided primarily because in Perl one of the main situations in which you hit the limits of Perl's inheritance model is
when your class needs to inherit from multiple different classes that containing clashing methods.
For example:
# If your class is like this
package Foo;
use base 'This', 'That';
1;
If both "This->method" exists and "That->method" exists, and both mean different things, then "Foo->method" becomes ambiguous.
A "Class::Adapter" could be used to wrap your "Foo" object, with the "Class::Adapter" becoming the "That" sub-class, and passing
"$decorator->method" through to "$object->that_method".
METHODS
Yes, "Class::Adapter::Builder" has public methods and later on you will be able to access them directly, but for now they are remaining
undocumented, so that I can shuffle things around for another few versions.
Just stick to the pragma interface for now.
SUPPORT
Bugs should be reported via the CPAN bug tracker at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Adapter>
For other issues, contact the author.
AUTHOR
Adam Kennedy <adamk@cpan.org>
SEE ALSO
Class::Adapter, Class::Adapter::Clear
COPYRIGHT
Copyright 2005 - 2010 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl v5.10.1 2010-04-12 Class::Adapter::Builder(3pm)