;-)
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 "
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
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
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
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
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
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
(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