# Getting output of command from run(pipeline(...)) in both stdout and file

**URL:** <https://discourse.julialang.org/t/getting-output-of-command-from-run-pipeline-in-both-stdout-and-file/116472>\
**Category:** General Usage\
**Created:** [July 1, 2024, 1:34pm UTC](https://discourse.julialang.org/t/getting-output-of-command-from-run-pipeline-in-both-stdout-and-file/116472 "2024-07-01T13:34:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Marchant](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablo_marchant/32/32828_2.png) [@Pablo\_Marchant](https://discourse.julialang.org/u/Pablo_Marchant)\
**Post date:** [July 1, 2024, 1:34pm UTC](https://discourse.julialang.org/t/getting-output-of-command-from-run-pipeline-in-both-stdout-and-file/116472/1 "2024-07-01T13:34:59Z")

</div>

Hi,

I’m trying to write a small script to setup simulations in a cluster. These take a while to compute, and while doing so provide useful output informing of the state of the simulation. For that purpose, when using bash, I’d run this as:

```julia
./rn | tee out.txt

```

where `rn` runs the simulations itself. Doing this gives me all the output in stdout, which is useful as the queuing system captures it and I can use it to evaluate the state of simulations during runtime. But I also want all that output to be saved together with the rest of the simulation output, which is why I use `tee` in here. In julia I could do:

```julia
run(pipeline(`./rn`, "out.txt"))

```

but that will silence everything coming to stdout. So is there a way to do both using `run(pipeline(...))`?

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [July 1, 2024, 8:56pm UTC](https://discourse.julialang.org/t/getting-output-of-command-from-run-pipeline-in-both-stdout-and-file/116472/2 "2024-07-01T20:56:27Z")

</div>

Try  
`run(pipeline(`./rn`, `tee out.txt`))`

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [July 1, 2024, 9:14pm UTC](https://discourse.julialang.org/t/getting-output-of-command-from-run-pipeline-in-both-stdout-and-file/116472/3 "2024-07-01T21:14:25Z")

</div>

You could use OutputCollectors.jl, it’s very handy for this: [OutputCollectors.jl Documentation · OutputCollectors.jl](https://juliapackaging.github.io/OutputCollectors.jl/stable/)

---

<div class="post-metadata">

**Author:** ![Pablo\_Marchant](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablo_marchant/32/32828_2.png) [@Pablo\_Marchant](https://discourse.julialang.org/u/Pablo_Marchant)\
**Post date:** [July 2, 2024, 7:49am UTC](https://discourse.julialang.org/t/getting-output-of-command-from-run-pipeline-in-both-stdout-and-file/116472/4 "2024-07-02T07:49:05Z")

</div>

Thanks @Jeff_Emanuel , that is precisely what I was looking for. @ericphanson , `OutputCollectors.jl` looks very useful, although in this case I want to see if everything I’m trying to do can be achieved with base julia.
