I have a shell script saved in scripts/shell/record_video.sh
that I need to call in one of my projects.
An example of its use in code:
(defn save-mp4 [cam filename duration]
(sh "scripts/shell/record_video.sh" (:i_url cam) filename (str duration)))
how would I be able to jar the project so that the shell script is included if i upload to clojars?
follow up
Thanks @Ankur. The (sh "bash" :in bash-command-string)
is super useful. The only reason I needed the .sh
file in the first place was because I couldn't quite figure out how to do redirects when the stdout contains something big (like a video).
the file scripts/shell/record_video.sh
contains:
SRC=rtsp://$1:554/axis-media/media.amp?resolution=1920x1080
DST=$2
LEN=$3
openRTSP -4 -d $LEN -w 1440 -h 1080 -f 25 -u root pass $SRC > $DST 2> /dev/null
and I did not know how to translate the redirect (>
) without making the program memory consumption enormous. The (sh "bash" :in bash-command-string)
command allows my function to be written without the shell script:
(defn save-mp4 [cam filename duration]
(let [src (format "rtsp://%s:554/axis-media/media.amp?resolution=1920x1080" (:i_url cam))
cmd (format "openRTSP -4 -d %d -w 1440 -h 1080 -f 25 -u root pass %s > %s 2> /dev/null"
duration src filename)]
(sh "bash" :in cmd)))