babashka: no such file or directory

454 Views Asked by At

I want to execute:

xlsx2csv ./mytest

And this works when i type and execute it, but when i use babashka it does not work:

source <(ls my* | bb -i '(map #(str "xlsx2csv " %) *input*)')
/proc/self/fd/11:1: no such file or directory: xlsx2csv mytest

What am i doing wrong here?

2

There are 2 best solutions below

0
On

I am not really sure, why to use Babashka for one step of the transformation, which basically only prefixes a filename with a command. If your filenames are "sane", this is just prefixing a string which could as well be done with sed or awk. And if they are "tricky" (as already pointed out in the comments), this won't cut it.

So may I suggest to use Babashka instead of a shell for all the work.

(ns script
  (:require [babashka.fs]
            [babashka.process]))

(defn xlsx2csv
  [file-name]
  (->
    (babashka.process/process ["xlsx2csv" file-name] {:out :inherit})
    (babashka.process/check)))

(run!
  xlsx2csv
  (babashka.fs/glob "." "*.xlsx"))
6
On
source =(ls my* | bb -i -o '(map #(str "xlsx2csv " % ) *input*)') >> test.csv

I forgot the -o option.