std.process spawnShell/pipeShell dont capture output of the shell
Colin Grogan
grogan.colin at gmail.com
Wed Oct 9 04:22:24 PDT 2013
Hi folks,
Is there anyway to make std.process.spawnShell or
std.process.pipeShell capture the output of the shell interface?
For example, the code:
import std.stdio;
import std.process;
void main(string[] args){
writefln("Executing: %s", args[1]);
auto processPipes = pipeShell(args[1], Redirect.all);
foreach(str; processPipes.stdout.byLine){
writefln("STDOUT: %s",str);
}
foreach(str; processPipes.stderr.byLine){
writefln("STDERR: %s",str);
}
}
is compiled to an executable called "mess".
When executed with the following produces:
"
~/test$ ./mess ls
Executing: ls
STDOUT: mess
STDOUT: text.txt
"
Thats all fine, however, I'd expect it to print another "~/test$"
at the end, as if its an interactive shell waiting for input.
Is that an incorrect assumption to make or am I doing something
wrong that is stopping that from happening?
Also, If I run /bin/bash through program, it hangs.
"
~/test$ ./mess /bin/bash
Executing: /bin/bash
"
Thanks,
Colin
More information about the Digitalmars-d-learn
mailing list