Re: calling external programs
- From: Nix <nix go-nix ca>
- To: gtk-app-devel-list gnome org
- Subject: Re: calling external programs
- Date: Sat, 18 Oct 2003 06:10:43 -0600
On Mon, 2003-10-13 at 11:01, Dave Mason wrote:
Hi,  I'm a newbie to gtk, and I need to call a system() function and have 
its output show up in a separate frame(?) or dialog box or window or 
something.  Do you just create the new widget, make it active, then make the 
system() call?  What's the recommended widget to use - a window?
In your shoes, I would call popen() instead:
FILE *pfile = popen ("ls -l", "r") ;
char buf[256] = "" ;
int ic = 0 ;
while (!feof (pfile))
  {
  ic = fread (buff, 1, 256, pfile) ;
  /* Now buf contains ic characters of output */
  }
pclose (pfile) ;
See, popen () allows you to treat the input XOR the output of a process
as a file.  This way, you can read from XOR write to it, respectively.
As for the widget to display the text, I'd say a GtkTextView would be a
solution.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]