# Piping directly to STDIN

**URL:** <https://discourse.julialang.org/t/piping-directly-to-stdin/2446>\
**Category:** General Usage\
**Created:** [March 4, 2017, 5:31pm UTC](https://discourse.julialang.org/t/piping-directly-to-stdin/2446 "2017-03-04T17:31:23Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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 4, 2017, 9:58pm UTC](https://discourse.julialang.org/t/piping-directly-to-stdin/2446/5 "2017-03-04T21:58:58Z")

</div>

Is this something like what you want?

```julia
let filename = tempname()
    open(filename,"w") do f
        println(f,"my answer!")
    end
    ret = open(filename) do f
        redirect_stdin(f) do
            user_input("what do you say?")
        end
    end
   
    println("\nresult was: ",ret) # for testing the test

    rm(filename)
    contains(ret, "my answer!") || error("test failed!")
end

```

(cribbed from the Julia test suite)

---

_[View the full topic](https://discourse.julialang.org/t/piping-directly-to-stdin/2446)._
