1

I want to see the entire output (not just the return value) of a script while it's executing via bash, like this:

#!/bin/sh    
cmd="$(script.py $arg)"

script.py prints multiple lines while executing, but I'm unable to see them in bash. Is there a way to maybe pipe the output to stdout?

2 Answers 2

1

this will display each line "produced" by your script while it is running:

while read line; do echo $line; done < <(script.py $arg 2>&1)

it will also, as suggested in the post above, redirect stderr to stdout

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

Comments

1

Perhaps it is being output to stderr. Try this:

#!/bin/sh    
cmd="$(script.py $arg 2>&1)"

Comments

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.