Re: getRuntime exec call?

2010-03-19 Thread alux
;-) I'm still at letter b in clojure.core. Grin. Regards, a. Meikel Brandmeyer schrieb: > Hi, > > On Fri, Mar 19, 2010 at 11:00:34AM -0700, alux wrote: > > > spels=> (make-array (.getClass "") 2 ) > > # > > spels=> (def arr (make-array (.getClass "") 2 )) > > #'spels/arr > > spels=> (aset arr 0 "

Re: getRuntime exec call?

2010-03-19 Thread Meikel Brandmeyer
Hi, On Fri, Mar 19, 2010 at 11:00:34AM -0700, alux wrote: > spels=> (make-array (.getClass "") 2 ) > # > spels=> (def arr (make-array (.getClass "") 2 )) > #'spels/arr > spels=> (aset arr 0 "write") > "write" > spels=> (aset arr 1 "c:\\config.sys") > "c:\\config.sys" > spels=> (.exec (Runtime/get

Re: getRuntime exec call?

2010-03-19 Thread Patrik Fredriksson
Also, have a look at http://richhickey.github.com/clojure-contrib/shell-api.html /Patrik On Mar 19, 7:00 pm, Michael Gardner wrote: > On Mar 19, 2010, at 6:07 AM, TimDaly wrote: > > > (defn cmdresult [cmdstr] > >  (let [args (into [] (seq (.split cmdstr " ")))] > >  (BufferedReader. > >    (Inpu

Re: getRuntime exec call?

2010-03-19 Thread Michael Gardner
On Mar 19, 2010, at 6:07 AM, TimDaly wrote: > (defn cmdresult [cmdstr] > (let [args (into [] (seq (.split cmdstr " ")))] > (BufferedReader. >(InputStreamReader. > (. (. (. Runtime (getRuntime)) (exec args)) > (getInputStream)) Why do (into [])? .exec expects a String[], exactly wha

Re: getRuntime exec call?

2010-03-19 Thread alux
Sorry, I'm a bit in a hurry ;-) You give a vector, it needs an array. Try something like: spels=> (make-array (.getClass "") 2 ) # spels=> (def arr (make-array (.getClass "") 2 )) #'spels/arr spels=> (aset arr 0 "write") "write" spels=> (aset arr 1 "c:\\config.sys") "c:\\config.sys" spels=> (.exec

Re: getRuntime exec call?

2010-03-19 Thread Tim Daly
The call I coded works if you only pass a string with no spaces. However, if the string has spaces there is no result. If you break the string into String[] then clojure cannot match the appropriate exec(String[]) method in Runtime. I do not know how to convince clojure to call this method. alux

Re: getRuntime exec call?

2010-03-19 Thread alux
The call to a static method is special, try (.exec (Runtime/getRuntime) "ls") Regards, alux TimDaly schrieb: > (defn cmdresult [cmdstr] > (let [args (into [] (seq (.split cmdstr " ")))] > (BufferedReader. > (InputStreamReader. > (. (. (. Runtime (getRuntime)) (exec args)) > (getInp

getRuntime exec call?

2010-03-19 Thread TimDaly
(defn cmdresult [cmdstr] (let [args (into [] (seq (.split cmdstr " ")))] (BufferedReader. (InputStreamReader. (. (. (. Runtime (getRuntime)) (exec args)) (getInputStream)) (defn readLine [cmdresult] (. cmdresult (readLine))) (def a (cmdresult "ls *.o")) This fails claiming: No