Tony Houghton <
h...@realh.co.uk> wrote:
>How about this?:
>
>import sys; print "Hit Enter",; sys.stdout.flush(); raw_input(""); print "OK"
>
>(although using print is a bit awkward these days with the transition
>from python 2 to 3).
OK, thanks. I didn't want to hack the "add-apt-repository" Ubuntu tool
itself, but it turned out to be easy to spot the text-output lines
describing what the tool was about to do followed by the user-prompt, so I
inserted "sys.stdout.flush()" there, and that works.
However, hacking stuff in /usr/bin is storing up trouble, so I'd rather
find a way to call the tool as-is with my bash script and still be able to
log its output. I was wondering why python is happy to output text to
stdout unless it's to a pipe making this flush command necessary. How
does it "know" that the pipe is there?