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

Hi, I am trying to run an external command from Julia using the run() function, but I am stuck on how to handle error codes and exit codes of any particular command. Previous Julia version had a readall() function, which isn’t available anymore.

Something like,

stdout,stderr = run(`some command`)

Although I do get the stacktrace and error printed on the console.(May be the default behaviour causes it to dump everything to STDOUT)

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))
    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.


@Ralph_Smith This was really helpful and helped me get running with the code. Thanks a lot!