title: Redirecting output of an external application started with glib
body: <p>I'm trying to use vala to start an external application using GLib with spawn_command_line_sync().
  According to the documentation (<a href="http://valadoc.org/#!api=glib-2.0/GLib.Process.spawn_sync" rel="nofollow">http://valadoc.org/#!api=glib-2.0/GLib.Process.spawn_sync</a>) you can pass a string to store the output of the external application.</p>
  
  <p>While this works fine when starting a script which prints a couple of lines, I need to call a program which will print the content of a binary file.
  (for example "cat /usr/bin/apt-get")</p>
  
  <p>Is there any way how I can receive the output of the external program not in a string, but in a DataStream or something like that ?</p>
  
  <p>I'm planning to write the ouput of the external program to a file, so just calling "cat /usr/bin/apt-get > outputfile" would be an alternative (not as nice), but it doesn't seem to work.</p>
  
  <p>Anyway I would prefer it to get some kind of Output Stream.
  I would appreciate any help.</p>
  
  <p>Code im using:</p>
  
  <pre><code>using GLib;
  
  static void main(string[] args) {
      string execute = "cat /usr/bin/apt-get";
      string output = "out";
  
      try {
          GLib.Process.spawn_command_line_sync(execute, out output);
      } catch (SpawnError e) {
          stderr.printf("spawn error!");
          stderr.printf(e.message);
      }
  
      stdout.printf("Output: %s\n", output);
  }
  </code></pre>