Redirecting the output of an inner process in a shell script - Unix

This is a discussion on Redirecting the output of an inner process in a shell script - Unix ; hi whatz up guys??? I have a small problem. when i run a cover shell script in Kshell, it calls some script (say XXX), which in turn calls other process(shell scripts) and c executables within it(XXX). Now if i redirect ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Redirecting the output of an inner process in a shell script

  1. Redirecting the output of an inner process in a shell script

    hi

    whatz up guys???

    I have a small problem.

    when i run a cover shell script in Kshell, it calls some script (say
    XXX), which in turn calls other process(shell scripts) and c
    executables within it(XXX).
    Now if i redirect the output of the main script using ( XXX 1> somefile
    ), i am not able to suppress the outputs of all its subprocesses. Some
    are going to the file, but some to the screen.

    I can make change only in the cover script, in the way in which i can
    invoke XXX.

    Guys please help.


  2. Re: Redirecting the output of an inner process in a shell script

    Anoop wrote:
    >
    > when i run a cover shell script in Kshell, it calls some script (say
    > XXX), which in turn calls other process(shell scripts) and c
    > executables within it(XXX).
    > Now if i redirect the output of the main script using ( XXX 1> somefile
    > ), i am not able to suppress the outputs of all its subprocesses. Some
    > are going to the file, but some to the screen.


    It doesn't make sense phrased that way. Rewrite XXX with the
    correction redirections.

    > I can make change only in the cover script, in the way in which i can
    > invoke XXX.


    XXX 2>&1 >1>somefile

    That will handle stderr, the most common other output file. If some
    program in the tree goes out of its way to write to /dev/tty you won't
    be able to incept as easily. passwd does that.


  3. Re: Redirecting the output of an inner process in a shell script

    On 2006-01-31, Anoop wrote:
    > hi
    >
    > whatz up guys???
    >
    > I have a small problem.
    >
    > when i run a cover shell script in Kshell, it calls some script (say
    > XXX), which in turn calls other process(shell scripts) and c
    > executables within it(XXX).
    > Now if i redirect the output of the main script using ( XXX 1> somefile
    > ), i am not able to suppress the outputs of all its subprocesses. Some
    > are going to the file, but some to the screen.
    >
    > I can make change only in the cover script, in the way in which i can
    > invoke XXX.


    Your redirection of stdout will be in effect for all of its
    subprocesses unless they themselves make some other redirection. If
    they print to stdout, then your redirection will be honoured.

    However, if they are printing to stderr, then you must also
    redirect that:

    XXX 1> somefile 2>&1

    If a process prints to, e.g., /det/tty instead of stdout, your
    redirection will not afftect it.

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  4. Re: Redirecting the output of an inner process in a shell script

    On 01/31/2006 12:34 PM, Anoop wrote:
    > hi
    >
    > whatz up guys???
    >
    > I have a small problem.
    >
    > when i run a cover shell script in Kshell, it calls some script (say
    > XXX), which in turn calls other process(shell scripts) and c
    > executables within it(XXX).
    > Now if i redirect the output of the main script using ( XXX 1> somefile
    > ), i am not able to suppress the outputs of all its subprocesses. Some
    > are going to the file, but some to the screen.
    >
    > I can make change only in the cover script, in the way in which i can
    > invoke XXX.
    >
    > Guys please help.
    >


    Like this maybe
    ( XXX ) 1> somefile 2>&1

    HTH

+ Reply to Thread