-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add STDERR pipe to readandwrite
#11824
Comments
readandwrite
should allow reading from STDERRreadandwrite
In the mean time, this function does what I need:
However, i don't see a clear way to refactor this to use the |
@vtjnash Sorry to resurrect this old issue... however, I get the feeling that 0.5 is getting close to release, and I know about |
questions should be asked on julia-users or stack overflow. But just to make sure my cleanup was successful, I tested the cleaned up version of your above function. Although, if you only need to run a single command, then using 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(`ls`)
julia> r = spawn(`ls -l VERSION`, (in, out, err))
julia> r = spawn(`ls -l VERSION`, (in, out, err))
julia> r = spawn(`ls -l VERSION`, (in, out, err))
julia> close(in); close(out.in); close(err.in);
julia> readstring(out)
"CONTRIBUTING.md\nDEBUGGER.md\nDISTRIBUTING.md\nHISTORY.md\nLICENSE.md\nMake.inc\nMake.user\nMakefile\nNEWS.md\nREADME.arm.md\nREADME.md\nREADME.windows.md\nVERSION\nui\nusr\nusr-staging\n-rw-r--r-- 1 jameson staff 10 Nov 10 2015 VERSION\n-rw-r--r-- 1 jameson staff 10 Nov 10 2015 VERSION\n-rw-r--r-- 1 jameson staff 10 Nov 10 2015 VERSION\n" |
Thanks, and sorry for the noise. The source of my problem here is that I don't see a documented way to access stderr from open(), and that both the spawn method you used and Pipe() are also undocumented. |
Almost 4 years later, it is still not documented. Could we at least document |
Sometimes it is necessary to have access to a process' STDIN, STDOUT and STDERR. In my case, I need to open pipes to an external command (specifically,
gnuplot
) that outputs text to both STDOUT and STDERR. With current commandreadandwrite()
, I can't read STDERR. This is on both 0.3 and master.I can redirect the process' STDERR to a file with
pipe()
, but that is not good enough in my case. The reason is that the process is long-lived; I want to issue a command to it by writing to its STDIN, and then read both STDOUT and STDERR to see if the command was successful. This may be repeated any number of times.I have tried redirecting STDERR to a
PipeBuffer
, but it doesn't work:The text was updated successfully, but these errors were encountered: