Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I'm trying to utilize the STDIN construct with Julia to read in the output of a unix command:
STDIN
#!/usr/bin/julia readline(STDIN)
Then in my terminal:
$ cat myfile.txt | ./pipe.jl
but I am not getting any output. What am I doing wrong?
You're not doing anything with the result of readline(STDIN). What kind of output do you want?
readline(STDIN)
Unlike the interactive REPL, a Julia script won't automatically print results. You need to explicitly print the resulting string:
print
print(readline(STDIN))
Add a comment
The line:
#!/usr/bin/julia
Has to be first, as Unix reads only the first line and checks it for #!. Also, you need to do:
#!
chmod +x pipe.jl
To make it work from ./pipe.jl construct.
./pipe.jl
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.