How to execute system commands?

后端 未结 3 854
攒了一身酷
攒了一身酷 2021-02-01 12:26

How can I execute system specific commands and get their response in Clojure? For example, let\'s assume we\'re on a Linux machine, how can I call top or free

3条回答
  •  醉话见心
    2021-02-01 13:16

    (use '[clojure.java.shell :only [sh]])
    (sh "free")
    (sh "top" "-bn1")
    

    See also: http://clojuredocs.org/clojure_core/clojure.java.shell/sh

提交回复
热议问题