Sponsored Content
Top Forums Shell Programming and Scripting Handling values with space while passing commandline argument from wrapper script in KSH Post 302364692 by kans on Friday 23rd of October 2009 04:29:48 PM
Old 10-23-2009
Handling values with space while passing commandline argument from wrapper script in KSH

Hi there,

I have a wapper script which passes the argument from command prompt to inner script.. It works fine as long as the argument containing single word. But when value contains multiple word with space, not working as expected. I tried my best, couldn't find the reason. Gurus, pls. help me.

Here is the code snippet :


#### Wrapper Begin #####
while getopts ":i:" OPTION 2>/dev/null
     case "$OPTION" in
          i) inargI=$OPTARG;;
         \?) print "Usage: $0 -i <ini>"
             exit -1 ;;
echo "$inargI"
#### Wrapper End #####


#### Inner Begin ####
while getopts ":i:j:" OPTION 2>/dev/null
     case "$OPTION" in
          i) inargI=$OPTARG;;
          j) inargJ=$OPTARG;;
         \?) print "Usage: $0 -i <job.ini> -j <job2.ini>"
             exit -1 ;;
echo "i=$inargI"
echo "j=$inargJ"
#### Inner End ####

When I run the arguments with out space, it works fine.

$ wrapper.sh -i "inner.sh -i \"Macain\" -j \"Obama\" "
inner.sh -i "Macain" -j "Obama" 

But When I run with space , the results are not showing as expected.

$ wrapper.sh -i "inner.sh -i \"John Macain\" -j \"Barack Obama\" "
inner.sh -i "John Macain" -j "Barack Obama" 

The expected result should be
i="John Macain"
j="Barack Obama"

Appreciate your help.

Thanks & Regards,

Last edited by kans; 10-23-2009 at 07:18 PM.. Reason: Moved the code into code space

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing argument from one script to other

Dear All, I have one script which accepts database name and user_id from the user, i have another script that will unload the data from all the tables based on the user_id accepted by the user. How can i pass the user_id from the 1st script to the other. My OS is sun solaris. Thanks in... (3 Replies)
Discussion started by: lloydnwo
3 Replies

2. Shell Programming and Scripting

New wrapper script will be developed to wrap two ksh scripts

Hi friend,:) The script should invoke these scripts sequentially! When one will finish the second will start. Please help me with it, thanks,:b: Ishai (3 Replies)
Discussion started by: ishai82
3 Replies

3. Shell Programming and Scripting

passing values to function in Ksh

Hi, I'm trying to work on the script given below #!/bin/ksh -x pfile() { echo "$1" } touch smp19 echo "Hi" > smp19 result=$(pfile $smp19) echo $result As highlighted , when i pass $smp19 as parameter ,it does not display the output.However when i try giving "Hi" instead... (2 Replies)
Discussion started by: Sheema
2 Replies

4. Shell Programming and Scripting

Passing commandline argument to a function

Hi, I have 2 ksh scripts. Script1.ksh contains function definition. script1.ksh function f1() { while getopts a:c: args do case $args in a) ARG1=$OPTARG ;; c) ARG2=$OPTARG ;; \?) echo "Error no valid Arguments passed" esac done echo $ARG1 echo $ARG2 script2.sh (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

5. Shell Programming and Scripting

Validating commandline argument

Hi, I am calling a script script2.shl from script1.shl as below script2.shl "TABLE_NAME" -r 10 In that I have to validate the parameter 4. i.e : it should be only 10 20 30 40 50 I know that I can do it by checking like below if ]; then echo "TRUE" else echo "FALSE" fi ... (3 Replies)
Discussion started by: mr_manii
3 Replies

6. Shell Programming and Scripting

Wrapper script Oracle look KSH

I have a KSH script that I want to call in a loop for each row in the above table --- new_script.ksh (psuedo code) the contents on this new script would be something like below... for t in (select table_name,schema_name from laod_table) loop /bin/load_table.ksh t.table_name... (4 Replies)
Discussion started by: vr23
4 Replies

7. Shell Programming and Scripting

passing argument in script?

hi, I want to implement some function to perform following task if ; then $TEXT = "Data_0" else $TEXT = $1 fi if ; then $Lines = 45 else $Lines = $2 fi Kindly suggest, thanks (11 Replies)
Discussion started by: nrjrasaxena
11 Replies

8. Shell Programming and Scripting

Help with Handling multiple argument in shell script

Hi i have written a shell script that takes only single ip address from the user and calculates its latency and reliability, can you please tell me that what should be done if i want that user should enter 100 or 1000 ip address (5 Replies)
Discussion started by: Preeti_17
5 Replies

9. Shell Programming and Scripting

sed commands success / fail from commandline vs ksh script

solaris 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Fire-T200 I need a sed command that tests true when presented with lines that contain either forward and backslash. input file: c:/myFile.txt c:\yourFile.txt It doesn't appear that sed (in my environment anyway) supports... (4 Replies)
Discussion started by: msutfin
4 Replies

10. Shell Programming and Scripting

Issue handling single quoted argument in shell script.

Below is my script that works fine and prints the desired output: #!/bin/ksh echo "$1" | while IFS= read -r dirpath do echo "DIRR_PATH:$dirpath" install_dir=$install_dir" "$dirpath done echo "Desired Output:$install_dir" Output: ./loopissue.sh... (10 Replies)
Discussion started by: mohtashims
10 Replies
IPESCRIPT(1)						      General Commands Manual						      IPESCRIPT(1)

ipescript - Run an Ipe script (written in Lua) SYNOPSIS
ipescript script { arguments } DESCRIPTION
ipescript runs an Ipe script written in Lua. The Ipe bindings are automatically available in the script. Ipescript looks for the script in any of the script directories. The script argument should not contain the .lua extension. ENVIRONMENT VARIABLES
ipescript respects the following environment variables: IPELATEXDIR the directory where ipetoipe runs Pdflatex. IPESCRIPTS a list of directories where Ipescript will look for scripts. When this variable is not set, Ipe searches first the current directory, then ~/.ipe/scripts, and finally the system-wide Ipe script directory. When this variable is set, it should contain a list of directories, separated by semicolons. A single under- score is replaced by the system-wide Ipe script directory. IPEDEBUG set this to 1 for debugging output from ipescript. AUTHOR
Please report bugs using Ipe bugzilla at http://ipe7.sourceforge.net/bugzilla.html SEE ALSO
Ipe is documented fully in The Ipe Manual, which is available online at http://ipe7.sourceforge.net/manual/manual.html . August 28, 2011 IPESCRIPT(1)

Featured Tech Videos

All times are GMT -4. The time now is 02:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy