I need to capture stdout and stderr of a win32 program i execute (either using open or spawn). I’ve followed the recomendation in #11824 and tried following:
julia> function popen3(cmd::Cmd) in = Pipe() out = Pipe() err = Pipe() r = spawn(cmd, (in, out, err)) return (in, out, err, r) end julia> in, out, err, r = popen3(`net file 0`)
net file 0 when executed from commandline (cmd.exe) as “net file 0 2>err.txt” produces stderr output into the file. However, if I do the recomended steps in Julia, pipes are empty.
If I run
julia> close(in); close(out.in); close(err.in);
julia hangs on the command close(err.in) and cannot be interrupted by ctrl-c.
if I skip the closing commands and try
julia hangs again
i have the feeling that the whole stream redirection is not functional under windows. Even when i try
julia> out, r = open(`net /?`)
The syntax of this command is:
NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP | HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ] (Pipe(closed => open, 0 bytes waiting),Process(`net /?`, ProcessExited(1)))
The output gets printed on REPL instead of being redirected to the out Pipe.
What am I doing wrong?