[Tutor] Getting process output in real time
Neil Hodge
hodge3@llnl.gov
Thu May 1 13:57:03 2003
Magnus:
Magnus Lyck=E5 wrote:
> At 08:40 2003-05-01 -0700, Neil Hodge wrote:
>=20
>> All:
>>
>> I am building a GUI to wrap around a CLI program. One of the=20
>> functions of the CLI outputs a progress bar, something like the=20
>> following:
>>
>> [0....25....50....75....100]
>>
>> I am using one of the os.popen variants for all of my other system=20
>> calls, and getting the stdout works perfectly. Since all of the other=
=20
>> functions are very quick or give no status updates, this would be a=20
>> moot question. But for this function, I would like to get the stdout=20
>> back in real time so that I can display it in the GUI. I note that in
>=20
>=20
> I don't think you can do this in a platform independent way.
> What operating system are we talking about?
>=20
Although I typically try to write platform-independently, that is not=20
necessary in this case. The OS is Linux.
I guess what I am looking for is something conceptually like the=20
following: a pipe that can be read from and can return the read data as=20
it arrives. I imagine this would involve threads as well: one thread to=20
read/return data from the pipe while it is still open, and another=20
thread to do something with that data.
Neil