This Blog continues on

Thursday, December 08, 2011

Running a subprocess with Dart and reading its output

Starting a foreign program, and reading its standard output stream is useful, and here is an example of listing the root directory.
void main() {
  Process p = new Process('/bin/ls', ['/']);
  StringInputStream stdoutStream = new StringInputStream(p.stdout);

  • Argument list does not include the executable name like it usually does
  • Use a StringInputStream to read an InputStream as a String
  • Close the process or the script will hang forever
Comments on Google+.