I’d like to get the result of my command line ‘pwd’ from my Dart console program.
I wait for the process to start, install the listeners and wait for the task to complete.
I don’t get the result though.
I guess that waiting for the first line makes the pwd to be executed BEFORE the listener could get a change to be installed.
I my guess is true, how can I rewrite the code then?
var process = await Process.start('pwd', []);
process.stdout.listen((data) {
print('stdout: $data');
});
process.stderr.listen((data) {
print('stderr: $data');
});
int exitCode = await process.exitCode;