Sponsored Content
Full Discussion: Parameter Passing problem
Top Forums Shell Programming and Scripting Parameter Passing problem Post 302336435 by Raamc on Wednesday 22nd of July 2009 06:17:44 AM
Old 07-22-2009
Parameter Passing problem

Hi All,

I developed a KSH script which will accept two parameters as input. These two parameters are some directories paths.

In the script i am validating the number of paramaters it received as below
#--------------------------------------
# Check Command line arguments
#--------------------------------------
if [ ${#} -ne 2 ]
then
echo " ${NOW} ${ScrName} : Invalid Parameter list..."
echo " ${NOW} ${ScrName} : Script needs TWO parameters"
echo " ${NOW} ${ScrName} : Param1--Input file path"
echo " ${NOW} ${ScrName} : Param2--Output file path"
exit 1
fi

and i am calling my script as
sh Script Name /home/raamch/work/infile /home/raamch/work/infile

script is giving the error as
+ [ 1 -ne 2 ]
+ echo Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Invalid Parameter list...
Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Invalid Parameter list...
+ echo Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Script needs TWO parameters
Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Script needs TWO parameters
+ echo Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Param1--Input file path
Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Param1--Input file path
+ echo Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Param2--Output file path
Wed Jul 22 04:42:27 CDT 2009 SELUPDFLE.sh : Param2--Output file path
+ exit 1


Even i tried the script calling as below
scriptname "path1" "path2"
scriptname "path1","path2"
scriptname 'path1' 'path2'

But no use.
script is not accepting the two parameters.

Please help me on how to pass directory paths as parameters to the KSH script.
 

10 More Discussions You Might Find Interesting

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

2. Programming

Passing parameter to makefile?

Hi, How to pass parameter to makefile? Please let me know if any one knows and also please put an example of makefile with this feature. thanks, Manju. (3 Replies)
Discussion started by: manju_p
3 Replies

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

4. Shell Programming and Scripting

Passing asterisk As A Parameter

I have written a Shell Script Program which accepts 3 parameters as shown below: ./calc 20 + 2 in the above line ./calc is the Shell Script itself with 3 parameters, namely: 20 + and 2. Well, now let's look inside the Script: result=$1$2$3 echo $result The output will be as... (8 Replies)
Discussion started by: indiansoil
8 Replies

5. Shell Programming and Scripting

Passing parameter in quotes

Hi, PW='/as sysdba'; export PW in other module I call sqlplus ${PW} (this line I unable to change!) How I can define PW so that sqlplus calls PW in quotes i.e sqlplus '/as sysdba' I tried like this PW="'/as sysdba'"; export PW - no luck Thanks in advance (2 Replies)
Discussion started by: zam
2 Replies

6. Shell Programming and Scripting

Positional parameter passing

Hi All, When passing parameters to a sheel script, the parameters are referenced by their positions such as $1 for first parameter, $2 for second parameter. these positional values can only have values ranging from $0-$9 (0,1,2,3...9). I have a shell script meant to accept 20 parameters. for... (3 Replies)
Discussion started by: ogologoma
3 Replies

7. Shell Programming and Scripting

Passing a parameter to AWK

Hi All, I am trying to pass a parameter to AWK on my KSH shell prompt as below. var1=2 echo $var1 awk -v var2=${var1} '{print var2}' testfile.txt I am passing the input file (testfile) to awk to get some o/p. It is having 10 records. When I run AWK, it is throwing the following errors... (1 Reply)
Discussion started by: Raamc
1 Replies

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

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

10. 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
SVN_DIFF(3)								 1							       SVN_DIFF(3)

svn_diff - Recursively diffs two paths

SYNOPSIS
array svn_diff (string $path1, int $rev1, string $path2, int $rev2) DESCRIPTION
Recursively diffs two paths, $path1 and $path2. Note This is not a general-purpose diff utility. Only local files that are versioned may be diffed: other files will fail. PARAMETERS
o $path1 - First path to diff. This can be a URL to a file/directory in an SVN repository or a local file/directory path. Note Relative paths will be resolved as if the current working directory was the one that contains the PHP binary. To use the calling script's working directory, use realpath(3) or dirname(__FILE__). Warning If a local file path has only backslashes and no forward slashes, this extension will fail to find the path. Always replace all backslashes with forward slashes when using this function. o $rev1 - First path's revision number. Use SVN_REVISION_HEAD to specify the most recent revision. o $path2 - Second path to diff. See $path1 for description. o $rev2 - Second path's revision number. See $rev1 for description. RETURN VALUES
Returns an array-list consisting of two streams: the first is the diff output and the second contains error stream output. The streams can be read using fread(3). Returns FALSE or NULL on error. The diff output will, by default, be in the form of Subversion's custom unified diff format, but an external diff engine may be used depending on Subversion's configuration. NOTES
Warning This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk. EXAMPLES
Example #1 Basic example This example demonstrates the basic usage of this function, and the retrieval of contents from the stream: <?php list($diff, $errors) = svn_diff( 'http://www.example.com/svnroot/trunk/foo', SVN_REVISION_HEAD, 'http://www.example.com/svnroot/branches/dev/foo', SVN_REVISION_HEAD ); if (!$diff) exit; $contents = ''; while (!feof($diff)) { $contents .= fread($diff, 8192); } fclose($diff); fclose($errors); var_dump($contents); ?> The above example will output: Index: http://www.example.com/svnroot/trunk/foo =================================================================== --- http://www.example.com/svnroot/trunk/foo (.../foo) (revision 23) +++ http://www.example.com/svnroot/branches/dev/foo (.../foo) (revision 27) // further diff output Example #2 Diffing two revisions of a repository path This example implements a wrapper function that allows a user to easily diff two revisions of the same item using an external repository path (the default syntax is somewhat verbose): <?php function svn_diff_same_item($path, $rev1, $rev2) { return svn_diff($path, $rev1, $path, $rev2); } ?> Example #3 Portably diffing two local files This example implements a wrapper function that portably diffs two local files, compensating for the realpath(3) fix and the back- slashes bug: <?php function svn_diff_local($path1, $rev1, $path2, $rev2) { $path1 = str_replace('\', '/', realpath($path1)); $path2 = str_replace('\', '/', realpath($path2)); return svn_diff($path1, $rev1, $path2, $rev2); } ?> SEE ALSO
SVN documentation on svn diff. PHP Documentation Group SVN_DIFF(3)
All times are GMT -4. The time now is 09:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy