Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some problems with quickstart example #2

Open
holtzermann17 opened this issue Aug 23, 2016 · 0 comments
Open

some problems with quickstart example #2

holtzermann17 opened this issue Aug 23, 2016 · 0 comments
Labels

Comments

@holtzermann17
Copy link

holtzermann17 commented Aug 23, 2016

Here's what I'm seeing when I run the quickstart example

(with-open [in  (clojure.java.io/input-stream  "README.md")             
            out (clojure.java.io/output-stream "line_count.txt")]
  (->pipe->                                           
   in
   [(exec ["grep" "java"])
    (exec ["wc" "-l"])]
   out))
;=> #pipes.job/job-ctl/reify--21836[{:status :pending, :val nil} 0x32e24e7f]
;;  Exception in thread "Exec Default Executor" java.io.IOException: Stream Closed
;;  at java.io.FileOutputStream.writeBytes(Native Method)
;;  at java.io.FileOutputStream.write(FileOutputStream.java:326)
;;  at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
;;  at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
;;  at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
;;  at clj_commons_exec.DefaultResultHandler.onProcessFailed(clj_commons_exec.clj:50)
;;  at org.apache.commons.exec.DefaultExecutor$1.run(DefaultExecutor.java:205)
;;  at java.lang.Thread.run(Thread.java:745)
(slurp "line_count.txt")
;=> ""

However, I'm able to run a variant of it with successful output and no error messages.

(def baos (java.io.ByteArrayOutputStream.))
;=> #'flowrweb.core/baos
(with-open [in  (clojure.java.io/input-stream  "README.md") out baos]
  (->pipe->                                           
   in
   [(exec ["cat" "README.md"])                        
    (exec ["wc" "-l"])]
   out))
;=> #pipes.job/job-ctl/reify--11259[{:status :pending, :val nil} 0x11bdd579]
(String. (.toByteArray baos) (. java.nio.charset.Charset defaultCharset))
;=> "157\n"
(.reset baos)
;=> nil
@bilus bilus added the bug label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants