How to execute system commands?

Viewed 16187

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, and get their results for further processing?

4 Answers

You could use the babashka library to run shell commands in Clojure. An example would be

#!/usr/bin/env bb
(require '[clojure.java.shell :refer [sh]])
(sh "top")
Related