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

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

    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.

3 Likes