AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  OUTPUT OF A SCRIPT

    Posted 01/23/08 05:24 AM

    Originally posted by: SGLFORUM


    How to pass the output of a script as the input of another script?
    #AIX-Forum


  • 2.  Re: OUTPUT OF A SCRIPT

    Posted 01/23/08 11:51 AM

    Originally posted by: bhead


    Without knowing what the ouput looks like and what the second script expects I can only guess. In a new script capture the output in a variable.

    OutPut=$(/mydirectory/myscript1.ksh)

    /mydirectory/second_script.ksh $OutPut

    Not sure if that'll work or not.

    Edit

    Those are displaying as being on one line, should be 2 lines.

    Message was edited by: bhead
    #AIX-Forum


  • 3.  Re: OUTPUT OF A SCRIPT

    Posted 01/24/08 05:31 AM

    Originally posted by: nagger


    Your question is very vague.
    If you mean within one script, how do I run a further script but get the data back in the first script then try something like this example.

    In a shell script you can use:

    cat /etc/passwd | while read i
    do
    echo the output was $i
    done

    Replace "cat /etc/passwd" with your script.
    the $i shell variable will be the lines of output from the command or sub script.

    If the second script returns just one line

    date | read j
    echo Data returned was $j

    or

    k=`date`
    echo variable k contains $k

    This actually works with multiple lines but its hard to extract just some of the data.

    Hope this helps, N
    #AIX-Forum


  • 4.  OUTPUT OF A SCRIPT

    Posted 01/28/08 01:12 AM

    Originally posted by: SGLFORUM


    > SGLFORUM wrote:
    > How to pass the output of a script as the input of another script?
    Let me explain in detail.

    I have two script, say "a.sh" & "b.sh". I am calling "a.sh" within "b.sh".

    In "a.sh" script, I have declared a variable, say "ndev=`lsdev -Cc tape`".

    Can I show the output of "ndev" through "b.sh" script without declaring the same variable (ndev) in script "b.sh"?

    Contents of a.sh:
    ****************
    ndev=`lsdev -Cc tape`

    Contents of b.sh:
    *****************
    sh a.sh
    echo $ndev

    Message was edited by: SGLFORUM
    #AIX-Forum


  • 5.  Re: OUTPUT OF A SCRIPT

    Posted 01/28/08 01:35 AM

    Originally posted by: esv


    SGLFORUM wrote:
    SGLFORUM wrote:
    How to pass the output of a script as the input of another script?
    Let me explain in detail.

    I have two script, say "a.sh" & "b.sh". I am calling "a.sh" within "b.sh".

    In "a.sh" script, I have declared a variable, say "ndev=`lsdev -Cc tape`".

    Can I show the output of "ndev" through "b.sh" script without declaring the same variable (ndev) in script "b.sh"?

    Contents of a.sh:
    ****************
    ndev=`lsdev -Cc tape`

    Contents of b.sh:
    *****************
    sh a.sh
    echo $ndev

    Message was edited by: SGLFORUM

    in order to inherit variables defined in a.sh, you have to call it using the following syntax..

    . a.sh ( dot a.sh)

    best regards,
    Enrique.
    #AIX-Forum