fizzed / blaze

Write your shell scripts on the JVM (java, kotlin, groovy, etc.)
115 stars 15 forks source link

Pipeline confusion? #8

Closed ghost closed 6 years ago

ghost commented 6 years ago

I'm trying to emulate this...

echo "Hello World" | mail -r me@mynetwork.com -s "Testing email" you@mynetwork.com

And here is what I've tried so far...

        pipeline()
                .pipeInput(Streamables.input(new ByteArrayInputStream("Hello World".getBytes(StandardCharsets.UTF_8))))
                .add(exec("mail").args("-r", "me@mynetwork.com").args("-s", "Testing email").arg("you@mynetwork.com"))
                .pipeOutput(Streamables.standardOutput())
                .run();

And

    exec("mail")
        .args("-r", "me@mynetwork.com")
        .args("-s", "Testing email")
        .arg("you@mynetwork.com")
        .pipeInput(Streamables.input(new ByteArrayInputStream("Hello World".getBytes(StandardCharsets.UTF_8)))
        .pipeOutput(Streamables.standardOutput())
        .run()

And both hang. If I hit CTRL+C, I get (Interrupt -- one more to kill letter). And this is what mail outputs when there is nothing coming in on stdin. So how do I pipe text to a process?

ghost commented 6 years ago

And mail is working. I've got a bash script that does an echo "something" | mail and the mail goes through fine.

jjlauer commented 6 years ago

@jinspo - looks like there was an issue with inputs not having their EOF passed thru in some cases. I pushed out v0.17.0 just now -- I can get mail now to work per your example with it. Can you give it a try?

jjlauer commented 6 years ago

Forgot to also mention Streamables.input() now supports text as a form of input too.

ghost commented 6 years ago

@jjlauer Works like a champ! Thanks for the quick turnaround! Now I can get rid of my bridge Bash scripts that do nothing but mail 😄

jjlauer commented 6 years ago

Perfect.