Mailinglist Archive: opensuse (1620 mails)

< Previous Next >
Re: [opensuse] I thought I knew the basics - "tee" not working as I expected
On Wed, Nov 12, 2014 at 10:21 AM, Anton Aylward
<opensuse@xxxxxxxxxxxxxxxx> 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 | tee output_file

I'm not getting any output in konsole nor in the output_file until the app

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

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 calls

grep -R "tty" *
./parsers/ construct.String('tty_name', 32),
./parsers/ terminal, _, _ = entry.tty_name.partition('\x00')
./parsers/ tty_name, _, _ = header.tty_name.partition('\x00')
./parsers/ if tty_name or hostname:
./parsers/ self.assertEqual(event_object.terminal, u'ttys002')
./parsers/ u'Terminal: ttys002')
./parsers/ (i.e. HTTP Request) and the prettyfied string
for the protocols.
./parsers/ pretty_name =
self.NAME_PAIR_TRANSLATION.get(name, name)
./parsers/ data_dict.setdefault(pretty_name, []).append(value)
./parsers/ self.assertEqual(event_object.terminal, u'tty4')
./parsers/ u'Terminal: tty4 '
./frontend/ self._printer = pprint.PrettyPrinter(indent=8)
./frontend/ eventtype_filename = ".{0:s}_evtt_{1:s}".format(
./frontend/ if os.path.isfile(eventtype_filename):
./frontend/ x = open(eventtype_filename, 'rb')
./frontend/ evttypes = pickle.load(x)
./frontend/ evttype_indices = pickle.load(x)
./frontend/ evttype_candidates = {}
./frontend/ if candidate in evttype_candidates:
./frontend/ evttype_candidates[candidate] += 1
./frontend/ evttype_candidates[candidate] = 1
./frontend/ evttypes = []
./frontend/ evttype_indices = {}
./frontend/ for candidate, score in
./frontend/ evttype_indices[candidate] = len(evttypes)
./frontend/ evttypes.append(candidate)
./frontend/ del evttype_candidates
./frontend/ x = open(eventtype_filename, 'wb')
./frontend/ pickle.dump(evttypes, x)
./frontend/ pickle.dump(evttype_indices, x)
./frontend/ return (evttypes, evttype_indices)

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups