On Wed, Nov 12, 2014 at 10:21 AM, Anton Aylward <opensuse@antonaylward.com> wrote:
On 11/12/2014 10:13 AM, Greg Freemyer wrote:
Is there a way to force tee to flush it's buffers? (Or tee may not be the problem.)
== details
I have an interactive program I want to capture the output of. It only has one prompt, then it runs to completion
It's a python app. I'm running inside konsole and my basic command is:
python preg.py | tee output_file
I'm not getting any output in konsole nor in the output_file until the app ends.
If I run it interactively, I get the prompt fine, but all the resulting output spits up on the screen and it is multiple screens of output.
I realize the program is not the greatest at creating savable output, but I didn't write it!
Two things come to mind.
The first is that a pipe takes stdout and connects to stdin. if the output of a program doesn't go to stdout or if it closes and reopens its output or if it sends output to /dev/tty, then its not going to stdout.
Yes it seems a crazy thing to do but there you are.
The second is to use 'script' and run in a sub shell and have the screen output all saved.
Or perhaps not if the idiot program decided to send to /dev/tty ...
Can you look at the source? You don't need to be a python programmer to recognise something like
... Open("/dev/tty ...
First, tee is successfully splitting the output. it goes to both the logfile and the screen. The issue is it doesn't go either place until the app ends. Not really cool for an interactive app! Anyway, there are 400 or so python source files (*.py) and yes I can look through the source extracted from the tarball. "grep /dev/tty" turns up nothing. 'grep tty" is more interesting. But I don't think any of these are what you are looking for. Note that the app parsers lots of file types looking for info, so the parsers folder is likely not worrying with user I/O. The frontend folder is likely full of various user I/O related front-ends to the parsers. I don't know if preg.py calls plasm.py. grep -R "tty" * ./parsers/utmpx.py: construct.String('tty_name', 32), ./parsers/utmpx.py: terminal, _, _ = entry.tty_name.partition('\x00') ./parsers/utmpx.py: tty_name, _, _ = header.tty_name.partition('\x00') ./parsers/utmpx.py: if tty_name or hostname: ./parsers/utmpx_test.py: self.assertEqual(event_object.terminal, u'ttys002') ./parsers/utmpx_test.py: u'Terminal: ttys002') ./parsers/pcap.py: (i.e. HTTP Request) and the prettyfied string for the protocols. ./parsers/cups_ipp.py: pretty_name = self.NAME_PAIR_TRANSLATION.get(name, name) ./parsers/cups_ipp.py: data_dict.setdefault(pretty_name, []).append(value) ./parsers/utmp_test.py: self.assertEqual(event_object.terminal, u'tty4') ./parsers/utmp_test.py: u'Terminal: tty4 ' ./frontend/pinfo.py: self._printer = pprint.PrettyPrinter(indent=8) ./frontend/plasm.py: eventtype_filename = ".{0:s}_evtt_{1:s}".format( ./frontend/plasm.py: if os.path.isfile(eventtype_filename): ./frontend/plasm.py: x = open(eventtype_filename, 'rb') ./frontend/plasm.py: evttypes = pickle.load(x) ./frontend/plasm.py: evttype_indices = pickle.load(x) ./frontend/plasm.py: evttype_candidates = {} ./frontend/plasm.py: if candidate in evttype_candidates: ./frontend/plasm.py: evttype_candidates[candidate] += 1 ./frontend/plasm.py: evttype_candidates[candidate] = 1 ./frontend/plasm.py: evttypes = [] ./frontend/plasm.py: evttype_indices = {} ./frontend/plasm.py: for candidate, score in evttype_candidates.iteritems(): ./frontend/plasm.py: evttype_indices[candidate] = len(evttypes) ./frontend/plasm.py: evttypes.append(candidate) ./frontend/plasm.py: del evttype_candidates ./frontend/plasm.py: x = open(eventtype_filename, 'wb') ./frontend/plasm.py: pickle.dump(evttypes, x) ./frontend/plasm.py: pickle.dump(evttype_indices, x) ./frontend/plasm.py: return (evttypes, evttype_indices) Thanks Greg -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org