1

Say I have a server at 01.23.456.789 and run the following command:

ssh 01.23.456.789 "python3 -c 'import time; print(1); time.sleep(10); print(2);'"

It prints 1 and 2 simultaneously after 10 seconds. Is there any way to get the individual output immediately, so I would get 1 printed, wait for 10 seconds, and get 2 printed?

1 Answer 1

1

Python buffers its outputs. You have to flush the buffer somehow, either from inside python or from outside using stdbuf -oL. You can also use python3 -u to automatically flush upon print.

ssh 01.23.456.789 "python3 -uc 'import time; print(1); time.sleep(10); print(2);'"
Sign up to request clarification or add additional context in comments.

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.