View script output over ssh in real time
Use the -u
flag to python:
cat printdelay.py | ssh user@host python -u
The behavior you're seeing is because, when writing to stdout when stdout is not an interactive device such as a tty or pty, the printf
family of functions flush the buffer less frequently. There's not a whole lot you can do about that except give Python a pty, as you discovered. This will work:
scp printdelay.py user@host:/tmp/timedelay.py
ssh -t user@host python /tmp/timedelay.py
(If you just cat timedelay.py | ssh -tt user@host python
, python will have a pty and it will flush the buffer more frequently, but you will have other issues, for instance your script will get printed to stdout due to the way that pty allocation works with ssh.)
You can also try using the coreutils command stdbuf.
Related videos on Youtube
![Anton](https://i.stack.imgur.com/PXHte.jpg?s=256&g=1)
Anton
Updated on September 18, 2022Comments
-
Anton almost 2 years
I have simple tableview with custom cell that contains uibutton. After update to iOS 9 GM or 9.1 Beta 1(it doesn't matter) button on cell stopped to response on touch. I have also create IBAction method inside cell class and it's also doesn't work at all
cell.username.setAttributedTitle(attrNameString, forState: .Normal) cell.username.tag = notify.likeObject.likedUserId.integerValue cell.username.addTarget(self, action: "showProfile:", forControlEvents: .TouchUpInside)
-
Shamas S almost 9 yearsEdit title of your question. Current title should be in tags.
-
-
thrig over 7 yearsOr with a suitable version
python -u
to unbuffer everything or usesys.stdout.flush
calls as appropriate orprint(flush=True)
and of course the usual debate over which is the most pythonic of these multiple ways to do things. -
SauceCode over 7 yearsThanks for the explanation. Perhaps you could move the mention of the '-u' flag to the top of the answer. It looks like the neatest solution to me.