I am trying to run a local script on a remote machine with ssh.
Let's say this is the python script (printdelay.py
) which I am trying to run:
from time import sleep print("The first line") sleep(10) print("The second line")
I execute the script like this:
cat printdelay.py | ssh user@host python
The script executes, but I noticed that I only see the output from the command once the whole script has finished running. I would like to see the output as the script executes, i.e. with a delay between printing the two lines.
I noticed that
cat printdelay.py | ssh -t -t user@host python
sort of does what I'm looking for, but then I see a lot of noise in the pseudo terminal, rather than the plain printing of the lines. I guess there is a better way to do this.