Find the answer to your Linux question:
Results 1 to 7 of 7
Hi all, I am facing a problem to declare variable which can handle null values. Here's the situation Code: export PARM5="$5" export PARM6="$6" export PARM7="$7" echo $FND_TOP/bin/CONCSUB $1 ONT 'Order ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2013
    Posts
    6

    Handling null values in shell script


    Hi all,
    I am facing a problem to declare variable which can handle null values.

    Here's the situation

    Code:
    export PARM5="$5"
    export PARM6="$6"
    export PARM7="$7"
     
    
     echo $FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT $PROGRAM "$PARM5" "$PARM6" "$PARM7"
    In the above code $5,$6,$7 may have null values,so how can I handle that.

    If i run the below line in command line it works fine

    Code:
    $FND_TOP/bin/CONCSUB apps/apps ONT 'Order Management Super User, Vision Operations (USA)' OPERATIONS WAIT=Y CONCURRENT ONT $PROGRAM '"12345"' '""' '""'
    When I run from shell script the null values aren't getting passed.
    Any suggestions are highly appreciated

    Thanks in advance!!

  2. #2
    Just Joined!
    Join Date
    May 2013
    Posts
    19
    It must be an issue quoting you vars. empty vars should be no problem.
    See my code, do I understand you well ?
    Code:
    #!/bin/bash
    
    a=""
    b=""
    c=""
    
    echo "$a" "$b" "$c" | ( \
    while read x y z
    do
            echo "<$x>" "<$y>" "<$z>"
            echo "$x" "$y" "$z" "aapje" | od -c | less
    done )
    NO No No, sorry, I am mistaken, I am losing the zero vars too.

    I modified the code a bit to see my failure.
    Code:
    #!/bin/bash
    
    a=""
    b="bear"
    c=""
    
    echo "$a" "$b" "$c" | ( \
    while read x y z
    do
            echo "<x$x>" "<y$y>" "<z$z>"
            echo "x$x" "y$y" "z$z" "aapje" | od -c | less
    done )
    Last edited by kuifje; 05-04-2013 at 08:19 PM. Reason: Mistaken.

  3. #3
    Just Joined!
    Join Date
    May 2011
    Location
    Central FL
    Posts
    91
    What do you mean by "null values aren't getting passed"?

    Please provide bash -x output for the script you're running so we can see where it fails, and also either the command-line or input that it is given - and the output both as it currently is - and as you're wanting the output to be - hard to understand what you're looking for otherwise.

  4. #4
    Just Joined!
    Join Date
    Mar 2013
    Posts
    6
    Quote Originally Posted by dayid View Post
    What do you mean by "null values aren't getting passed"?

    Please provide bash -x output for the script you're running so we can see where it fails, and also either the command-line or input that it is given - and the output both as it currently is - and as you're wanting the output to be - hard to understand what you're looking for otherwise.
    This works from command line
    Code:
    $FND_TOP/bin/CONCSUB apps/apps ONT 'Order Management Super User, Vision Operations (USA)' OPERATIONS WAIT=Y CONCURRENT ONT $PROGRAM '"12345"' '""' '""'
    When I execute the same from shell script based conc program in oracle apps,I did a echo and observed that the below is getting passed

    Code:
    #!/bin/bash
    export PARM5="$5"
    export PARM6="$6"
    export PARM7="$7"
     
    echo "INTPARM5=\"$PARM5\"" 
    echo "INTPARM6=\"$PARM6\"" 
    echo "INTPARM7=\"$PARM7\"" 
     
     echo $FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT $PROGRAM "$INTPARM5" "$INTPARM6" "$INTPARM7"
    o/p

    Code:
    $FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT $PROGRAM

  5. #5
    Just Joined!
    Join Date
    Mar 2013
    Posts
    6
    Quote Originally Posted by kuifje View Post
    It must be an issue quoting you vars. empty vars should be no problem.
    See my code, do I understand you well ?
    Code:
    #!/bin/bash
    
    a=""
    b=""
    c=""
    
    echo "$a" "$b" "$c" | ( \
    while read x y z
    do
            echo "<$x>" "<$y>" "<$z>"
            echo "$x" "$y" "$z" "aapje" | od -c | less
    done )
    NO No No, sorry, I am mistaken, I am losing the zero vars too.

    I modified the code a bit to see my failure.
    Code:
    #!/bin/bash
    
    a=""
    b="bear"
    c=""
    
    echo "$a" "$b" "$c" | ( \
    while read x y z
    do
            echo "<x$x>" "<y$y>" "<z$z>"
            echo "x$x" "y$y" "z$z" "aapje" | od -c | less
    done )

    Your method seems to be working but I have a doubt on the order of parameters being passed

    This is how my changed script looks
    Code:
    #!/bin/bash
    set -x
    export PARM5="$5"  
    export PARM6="$6"
    export PARM7="$7"
    
    
    
    echo "$PARM5" "$PARM6" "$PARM7" | ( \
    while read x y z
    do
            echo "<x$x>" "<y$y>" "<z$z>"
            echo "x$x" "y$y" "z$z" | od -c | less
    done )
    
    
    
     REQ_ID=`$FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT XXKES_PDF_REPORT_SUBMIT $PARM5 $PARM6 $PARM7`
    For $5 I am passing the value 66432 and for $7 the value is Mixed.

    But my shell script log looks something like this

    Code:
    + export PARM5=66432
    + PARM5=66432
    + export PARM6=
    + PARM6=
    + export PARM7=Mixed
    + PARM7=Mixed
    + echo 66432 '' Mixed
    + read x y z
    + echo '<x66432>' '<yMixed>' '<z>'
    <x66432> <yMixed> <z>
    + echo x66432 yMixed z
    + od -c
    + less
    0000000   x   6   6   4   3   2       y   M   i   x   e   d       z  \n
    0000020
    + read x y z
    ++ /u01/E-BIZ/apps/apps_st/appl/fnd/12.0.0/bin/CONCSUB APPS/APPS ONT 'Order Management Super User, Vision Operations (USA)' OPERATIONS WAIT=Y CONCURRENT ONT XXKES_PDF_REPORT_SUBMIT 66432 Mixed
    + REQ_ID='Submitted request 5831784 for CONCURRENT ONT XXKES_PDF_REPORT_SUBMIT 66432 Mixed
    Why the value Mixed is assigned to y? shouldn't it go for z..I am not good at shell programming so sorry if I am asking some silly doubts.

  6. #6
    Just Joined!
    Join Date
    May 2013
    Posts
    19
    What you see is just the problem , empty vars are lost when send in one line.
    If you could send the vars one by one, then there would be a '/n' as separator.
    Any other separator would be fine too, when send in one row but the recieving program has to be aware of the chosen method/separator.
    I think there is no other way.

  7. #7
    Just Joined!
    Join Date
    May 2013
    Posts
    19
    Did some extra test.. Try this
    Code:
    echo "a" "b" | while read x; do echo "$x" ; done
     echo "a" "" "" "" "" "" "b" | while read x; do echo "$x" ; done
    And see the difference in output, but how would a recieving program know if it is an empty var or not.
    The second line could even have a var of several spaces.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •