2

I'm trying to run a Windows command from a Clojure program. I am testing it with a small echo statement:

(:require [clojure.java.shell :as sh])

(defn testcal [cob]
  (let [cmd (str "echo hi" )
        result (sh/sh cmd)]))

Its throwing me the following error:

Exception in thread "main" java.io.IOException: Cannot run program "echo hi": CreateProcess error=2, The system cannot find the file specified

My java path looks good and checked everything. Can someone help me with this?

Richard Erickson
  • 2,520
  • 8
  • 26
  • 36
Sri
  • 411
  • 1
  • 6
  • 16

1 Answers1

1

in windows environment, instead of

(sh/sh "echo hi")

try

(sh/sh "cmd" "/C" "echo hi")

the answer of why "cmd" "/C" is here https://stackoverflow.com/a/4031412/1393248

Community
  • 1
  • 1
mavbozo
  • 1,151
  • 8
  • 10