1

I have script1 which calls script2 which contains an echo statement. I want script1 to send the echo returned by the script2 to a named_pipe. Is there a way to do it without having to change the code of script2? Like "capturing" the echo statements?

SCRIPT1:

...
case ${input_args[0]} in
        SCRIPT2)
            ./SCRIPT2.sh ${input_args[1]};;
...

SCRIPT2:

echo "OK: done!"
0

1 Answer 1

2

Just redirect the output to the named pipe:

./SCRIPT2.sh ${input_args[1]} >"my_named_pipe"

Named pipes are just like files in this sense.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Tamas, I did like that but there where other issues in the code which prevented it to work. Now is working fine. The only problem is that if in SCRIPT2 you have multiple echo statement, they are not printed well :(... any tips?
So you want to send the output of SCRIPT2 both to the terminal and the named pipe? In that case you can use tee like this: ./SCRIPT2.sh ${input_args[1]} | tee "my_named_pipe"
Thank you tamas! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.