I did this:
(import '(java.io BufferedReader InputStreamReader))
(defn cmd [p] (.. Runtime getRuntime (exec (str p))))
(defn cmdout [o]
(let [r (BufferedReader.
(.InputStreamReader.
(.getInputStream o)))]
(dorun (map println (line-seq r)))))
Then:
(cmdout (cmd "ls -a"))
On Aug 25, 8:00 am, Parth Malwankar <[EMAIL PROTECTED]> wrote:
> I want to run a shell command through Clojure
> so I tried the following which doesn't work:
>
> user=> (.. Runtime (getRuntime) (exec "vim"))
> [EMAIL PROTECTED]
> user=> (.. Runtime (getRuntime) (exec "/usr/bin/vim"))
> [EMAIL PROTECTED]
> user=> (.. Runtime (getRuntime) (exec "ls"))
> [EMAIL PROTECTED]
>
> I may be doing something really silly here as I
> don't really know Java. Whats the right way to do this?
>
> Thanks.
> Parth
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---