The Artima Developer Community
Sponsored Link

Java Buzz Forum
Executing A Command Line Program With Clojure

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Sam Newman

Posts: 800
Nickname: padark
Registered: Feb, 2004

Sam Newman is quite lazy
Executing A Command Line Program With Clojure Posted: Jun 20, 2010 6:03 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Sam Newman.
Original Post: Executing A Command Line Program With Clojure
Feed Title: magpiebrain
Feed URL: http://feeds.feedburner.com/Magpiebrain
Feed Description: A Java Blog
Latest Java Buzz Posts
Latest Java Buzz Posts by Sam Newman
Latest Posts From magpiebrain

Advertisement
Making use of clojure.contrib.duck-streams: (ns utils (:use clojure.contrib-duck-streams)) (defn execute [command] (let [process (.exec (Runtime/getRuntime) command)] (if (= 0 (.waitFor process)) (read-lines (.getInputStream process)) (read-lines (.getErrorStream process)))) ... user=> (execute "ls") ("MyProject.iml" "lib" "out" "src" "test") It could be improved obviously – for example catching some of the potential IOExceptions that can result to rethrow [...]

Read: Executing A Command Line Program With Clojure

Topic: Group pattern matching with regular expressions in Java and Scala Previous Topic   Next Topic Topic: Apache Aries: Enterprise OSGi in Practice

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use