Last active
July 19, 2024 13:29
-
-
Save gerritjvv/5866665 to your computer and use it in GitHub Desktop.
Calling an external process from Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(comment | |
This is the easiest and most concise way of calling an external process in Java. The inheritIO methods causes the command to output stdout and errout to the same place as your current process (which most of the times is the console), no need to create mechanisms for reading asynchronously from input streams to get at the information. | |
http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html | |
) | |
(def ret (.waitFor (-> (ProcessBuilder. ["gzip" "-t" "g.txt.gz"]) .inheritIO .start))) | |
Ditto - just what I was looking for.
@GlennS clojure.java.shell/sh
does not solve the same problem this does, because it does not redirect IO to the subprocess.
@gerritjvv--thank you, this is exactly what I needed.
Thanks!!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is gold. Thanks for posting it.