# How to handle error statuses and exit codes in Julia while invoking external commands?

**URL:** <https://discourse.julialang.org/t/how-to-handle-error-statuses-and-exit-codes-in-julia-while-invoking-external-commands/9768>\
**Category:** General Usage\
**Tags:** question, query\
**Created:** [March 17, 2018, 7:48am UTC](https://discourse.julialang.org/t/how-to-handle-error-statuses-and-exit-codes-in-julia-while-invoking-external-commands/9768 "2018-03-17T07:48:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [March 17, 2018, 5:03pm UTC](https://discourse.julialang.org/t/how-to-handle-error-statuses-and-exit-codes-in-julia-while-invoking-external-commands/9768/2 "2018-03-17T17:03:27Z")

</div>

`run` is not very flexible.  
The following seems to work on v0.6.2 and a recent nightly:

```julia
    cmd = `some command`
    err = Pipe()
    out = Pipe()
    proc = spawn(pipeline(ignorestatus(cmd),stdout=out,stderr=err))
    close(err.in)
    close(out.in)
    println("stdout: ",String(read(out)))
    println("stderr: ",String(read(err)))
    println("status: ",proc.exitcode)

```

I don’t know if this is recommended usage, but it is based on what I learned from the test suite.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-handle-error-statuses-and-exit-codes-in-julia-while-invoking-external-commands/9768)._
