# How to capture stdout and stderr in \<1.1?

**URL:** <https://discourse.julialang.org/t/how-to-capture-stdout-and-stderr-in-1-1/20712>\
**Category:** General Usage\
**Created:** [February 12, 2019, 4:45pm UTC](https://discourse.julialang.org/t/how-to-capture-stdout-and-stderr-in-1-1/20712 "2019-02-12T16:45:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [February 12, 2019, 4:45pm UTC](https://discourse.julialang.org/t/how-to-capture-stdout-and-stderr-in-1-1/20712/1 "2019-02-12T16:45:02Z")

</div>

The following works in 1.1 but fails in earlier versions.  
What would be the right/best way to capture both stdout and stderr in \<1.1?

```julia
stdout_buf = IOBuffer()
stderr_buf = IOBuffer()
run(pipeline(ignorestatus(cmd), stdout=stdout_buf, stderr=stderr_buf))

```

I appreciate that 1.1 has IOBuffer() and spawn interaction changes, but for reference, this is the error in 1.0.3 on macos:

```julia
ERROR: MethodError: no method matching rawhandle(::Base.GenericIOBuffer{Array{UInt8,1}})

```

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [February 13, 2019, 4:04am UTC](https://discourse.julialang.org/t/how-to-capture-stdout-and-stderr-in-1-1/20712/2 "2019-02-13T04:04:25Z")

</div>

Self-answering given that this seems to work:

```julia
out = Pipe()
err = Pipe()
p = Base.open(pipeline(ignorestatus(cmd), stdout=out, stderr=err))
close(out.in); close(err.in)
err_s = readlines(err)
out_s = readlines(out)

```
