Fork me on GitHub

Is it possible to do an input redirection in shell with Babashka tasks? I would like to make a script like: mysql --login-path=mydb db < db_backup.sql But I get an error when I use the "<" character. This did not work: (shell {:out "out.txt" } "mysql -h localhost -u user -pPASSWD db < db_backup.sql") Is there any other way to pass the contents of a file into a shell script?

borkdude10:02:26 yes! use (shell {:in (io/file "db_backup.sql")} ...)


Oh thanks, I'll try that!


Yes, that did work, thanks!

Mícheál Ó Catháin16:02:40

hi! I'm getting a great kick out of learning Babashka. Has anyone managed to use it to access currency exchange rates via a web api?


Is your question: how you can you access a web api in babashka?


there are a couple more options for doing http but that's a convenient one

Mícheál Ó Catháin16:02:00

@U04V15CAJ thank you - that is essentially my question yes!

Mícheál Ó Catháin16:02:34

I am trying babashka.curl just now...

Mícheál Ó Catháin17:02:48

Thanks so much @U04V15CAJ. It just works!

👍 1
Mícheál Ó Catháin17:02:23

(require '[babashka.curl :as curl])                                 
(require '[cheshire.core :as json])    (def resp (curl/get "" {:headers {\
  "Accept" "application/json"}}))                                     
(def body (json/parse-string (:body resp)))                         
(println (str "EUR:USD = " (get body "EUR_USD")))

🎉 2
☘️ 1
Ben Sless20:02:32

Is it possible to use babashka to run clojure


Do you mean, to invoke a -Tfoobar tool?


The project seems to work under the following conditions: • include babashka/spec.alpha • include the tools-deps-native pod (which brings in tools.deps.alpha via a pod)

$ bb -cp $(clojure -Spath -Sdeps '{:deps {org.babashka/spec.alpha {:git/url "" :sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}}') -e "(babashka.pods/load-pod 'org.babashka/tools-deps-native \"0.0.5\")' "-e "(require '[])"


But it requires further testing. So I'd say: it could work, but I'm not sure if it's worth pursuing.

Ben Sless04:02:09

Motivation - I want fast start up times for tools introspection


I noticed when creating the Self contained bb executable with caxa that it takes ages to create and ages to start the executable for the first time. Is it perhaps related to the mac's M1 processor (lot's of issues seem to be related to it these days:)


@U96LS78UV Make sure that your directory doesn't contain any garbage and doesn't contain an executable you created before since it will package itself within the new executable. I.e. have the least amount of files in the directory so the binary will be the smallest possible.


I don't have experience on m1, but I'll try what a hello world yields here:


It takes around 10s or so. Image is around 50mb. First time takes a while to invoke, but second time is way faster.


Yes, actually this was the case. When I cleared all the nonsense from the folder it started to work really fast. I need a bb task wrapper for the caxa command to remove the old executable first : )


Or move everything to a separate dir and use a different input argument

✔️ 1

ha, that's even simpler: ) after cleaning it up it takes ~ 6 seconds. great stuff!


why the exec file is about 34MB? for a script of 100 B? )


because it compresses babashka inside of that binary