Fork me on GitHub
#babashka
<
2020-04-21
>
dabrazhe08:04:20

Hi. What's the best way to execute a bash command in a bb script? eg smth like

(let [buck $(aws s3 ls)] println buck)

borkdude08:04:10

@dennisa something like this: (require '[clojure.java.shell :refer [sh]]) (let [buck (-> (sh "aws "s3" "ls") :out)] (println buck))

hugo11:04:53

if you specify options after --nrepl-server with no args, for instance --nrepl-server --classpath . the option after is interpreted as an arg to --nrepl-server

borkdude11:04:07

@hybas3 Ah, that's a bug. Feel free to post an issue. For now just give it a port number 1667

dabrazhe11:04:47

Thanks! is there a way to it with bb command ? I am missing smth

bb "(require '[clojure.java.shell :refer [sh]]) (let [buck (-> (sh "aws" "s3" "ls") :out)] (println buck))"
clojure.lang.ExceptionInfo: Could not resolve symbol: aws [at line 1, column 64]

borkdude12:04:02

@dennisa You are passing a string, but you're also using strings inside that string. You need to escape the inner double quotes.

borkdude12:04:06

Just try the code from a file, that's easier

souenzzo13:04:53

@dennisa you can do echo bb "(require '[clojure.java.shell :refer [sh]]) (let [buck (-> (sh "aws" "s3" "ls") :out)] (println buck))" to see what bb actualy running

👍 1
dabrazhe15:04:31

Would you consider adding java shell by default to the class path, so that require won't be required? it will make using (sh) function much easier and would work from the command line.

borkdude15:04:32

@dennisa from the command line you can use (shell/sh ...)

😀 1
borkdude15:04:45

without the require

dabrazhe15:04:59

Great, it's already there

hugo11:04:00

Done 🙂

👍 2
hugo13:04:14

Woah, that was quick! Thanks