# Find whether a Julia script has the output redirected to the screen or a pipe?

**URL:** <https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365>\
**Category:** General Usage\
**Tags:** question, pipes, terminal\
**Created:** [June 14, 2023, 8:46pm UTC](https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365 "2023-06-14T20:46:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [June 14, 2023, 8:46pm UTC](https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365/1 "2023-06-14T20:46:32Z")

</div>

How do I find whether a Julia script running in the terminal has the output (stdout) redirected to the screen or a pipe?

```julia
$ ./julia_script # outputs to the terminal

```

```julia
$ ./julia_script | command # pipes the output

```

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [June 14, 2023, 8:59pm UTC](https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365/2 "2023-06-14T20:59:28Z")

</div>

The type of `stdout` should help you determine that:

```julia
$ julia -e 'println(typeof(stdout))'
Base.TTY

$ julia -e 'println(typeof(stdout))' | cat
Base.PipeEndpoint

```

---

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [June 14, 2023, 9:48pm UTC](https://discourse.julialang.org/t/find-whether-a-julia-script-has-the-output-redirected-to-the-screen-or-a-pipe/100365/3 "2023-06-14T21:48:31Z")

</div>

Wow. Excellent!  
Thank you!
