Re: redirecting stdout to a text widget



On Wed, 2003-01-22 at 15:44, Janelle Contreras wrote:
Ok, I need help on how to redirect stdout to a text widget.  I am writing a
gui type shell used in the debug mode of our software, and many of the
libraries use printf's to make debugging comments.  Also the commands for
the shell that the gtk gui is executing use printf's to show their help
messages.  Anyway, I need to be able to redirect text that is going to
stdout through the printf's to my text widget.  I have seen some examples on
previous lists - mostly in perl which I am unfamiliar with.  My application
is in C.  I have also seen references to popen, but I am not sure how to use
it in my context.  I could direct it all to a file, and then read the file,
but it seams there would be a better way. 

A couple of things come to mind.  There's popen.  That creates a pipe,
runs an application and connects it's standard out to the pipe (maybe
standard in to, so you can control the app).

You'll also have to set the file descriptor returned by popen to allow
non-blocking reads.  Otherwise you don't always get data right away.

I can think of quite a few apps on freshmeat that are frontends to
commandline apps.  Their source code will probably help show how this
can all be accomplished.

Michael



Thanks for any help in advance!!

Janelle



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]