Sponsored Content
Top Forums Shell Programming and Scripting Position independent Parameter passing Post 302135469 by vino on Monday 10th of September 2007 03:44:57 AM
Old 09-10-2007
Perhaps this.

Code:
[/tmp]$ cat try.ksh
#! /bin/ksh
#

while [ $# -gt 0 ] 
do
    key=${1%=*}
    case $key in
        "-Dparameter1") echo "Param1=[${1#$key=}]" ;;
        "-Dparameter2") echo "Param2=[${1#$key=}]" ;;
    esac
    shift;
done
    
[/tmp]$ ./try.ksh -Dparameter1="something" -Dparameter2="more"
Param1=[something]
Param2=[more]
[/tmp]$ ./try.ksh -Dparameter2="more" -Dparameter1="something"
Param2=[more]
Param1=[something]
[/tmp]$

You can add more flags within the case-esac construct.
 

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
Config::YAML(3pm)					User Contributed Perl Documentation					 Config::YAML(3pm)

NAME
Config::YAML - Simple configuration automation VERSION
Version 1.42 SYNOPSIS
Config::YAML is a somewhat object-oriented wrapper around the YAML module which makes reading and writing configuration files simple. Handling multiple config files (e.g. system and per-user configuration, or a gallery app with per-directory configuration) is a snap. use Config::YAML; # create Config::YAML object with any desired initial options # parameters; load system config; set alternate output file my $c = Config::YAML->new( config => "/usr/share/foo/globalconf", output => "~/.foorc", param1 => value1, param2 => value2, ... paramN => valueN, ); # integrate user's own config $c->read("~/.foorc"); # integrate command line args using Getopt::Long $rc = GetOptions ( $c, 'param1|p!', 'param2|P', 'paramN|n', ); # Write configuration state to disk $c->write; # simply get params back for use... do_something() unless $c->{param1}; # or get them more OO-ly if that makes you feel better my $value = $c->get_param2; METHODS
new Creates a new Config::YAML object. my $c = Config::YAML->new( config => initial_config, output => output_config ); The "config" parameter specifies the file to be read in during object creation. It is required, and must be the first parameter given. If the second parameter is "output", then it is used to specify the file to which configuration data will later be written out. This positional dependency makes it possible to have parameters named "config" and/or "output" in config files. Initial configuration values can be passed as subsequent parameters to the constructor: my $c = Config::YAML->new( config => "~/.foorc", foo => "abc", bar => "xyz", baz => [ 1, 2, 3 ], ); get_*/set_* If you'd prefer not to directly molest the object to store and retrieve configuration data, autoloading methods of the forms "get_[param]" and "set_[param]" are provided. Continuing from the previous example: print $c->get_foo; # prints "abc" my $val = $c->get_quux; # $c->{quux} doesn't exist; returns undef $c->set_bar(30); # $c->{bar} now equals 30, not "xyz" my @list = qw(alpha beta gamma); $c->set_baz(@list); # $c->{baz} now a reference to @list fold Convenience method for folding multiple values into the config object at once. Requires a hashref as its argument. $prefs{theme} = param(theme); $prefs{format} = param(format); $prefs{sortby} = param(order); $c->fold(\%prefs); my $format = $c->get_format; # value matches that of param(format) read Imports a YAML-formatted config file. $c->read('/usr/share/fooapp/fooconf'); "read()" is called at object creation and imports the file specified by "new(config=>)", so there is no need to call it manually unless multiple config files exist. write Dump current configuration state to a YAML-formatted flat file. $c->write; The file to be written is specified in the constructor call. See the "new" method documentation for details. DEPRECATED METHODS
These methods have been superceded and will likely be removed in the next release. get Returns the value of a parameter. print $c->get('foo'); set Sets the value of a parameter: $c->set('foo',1); my @paints = qw( oil acrylic tempera ); $c->set('paints', @paints); AUTHOR
Shawn Boyette ("<mdxi@cpan.org>") Original implementation by Kirrily "Skud" Robert (as "YAML::ConfigFile"). BUGS
o Config::YAML ignores the YAML document separation string ("---") because it has no concept of multiple targets for the data coming from a config file. Please report any bugs or feature requests to "bug-yaml-configfile@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT &; LICENSE Copyright 2004 Shawn Boyette, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-03-07 Config::YAML(3pm)
All times are GMT -4. The time now is 05:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy