Re: g_spawn & g_io_channel: part II



On Tuesday 02 March 2004 20:26, Vladimir Djokic wrote:

    There's a code in attachment, if someone can give me a hint: all I
want is to start a shell command and print out its stdout and stderr
values.

Haven't looked at it in detail, but doing

  g_free(line);
  g_print("%s\n", line);

doesn't look right.

I've attached a small program that spawns a program (wget) and uses io 
channels to read its stdout and stderr from the pipes. It saves stdout in a 
buffer, and prints stderr to the text view. If you rename the stdout and 
stderr iochannel callback functions (ie. swap their names), you'll get stdout 
in the text view instead Should be easy enough to adapt for your purposes.

Cheers
-Tim

Attachment: spawn-async-with-pipes-gtk.c.gz
Description: GNU Zip compressed data



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