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 could i jar the project so that the shell script is included if i load in clojars?
tracking
Thanks @Ankur. (sh "bash" :in bash-command-string) super helpful. The only reason I needed the .sh file in the first place was because I couldn't figure out how to do redirects when stdout contains something big (like video).
The 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 redirection ( > ) without increasing program memory consumption. The command (sh "bash" :in bash-command-string) allows my function to be written without a 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)))
source share