1

I'm trying to utilize the STDIN construct with Julia to read in the output of a unix command:

#!/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?

2 Answers 2

5

You're not doing anything with the result of readline(STDIN). What kind of output do you want?

Unlike the interactive REPL, a Julia script won't automatically print results. You need to explicitly print the resulting string:

print(readline(STDIN))
Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

It is... I added the filename only here

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.