clojure – 如何将shell脚本打包到leiningen项目中
发布时间:2020-12-15 21:08:24 所属栏目:安全 来源:网络整理
导读:我有一个保存在scripts / shell / record_video.sh中的shell脚本,我需要在我的一个项目中调用它. 它在代码中使用的一个例子: (defn save-mp4 [cam filename duration] (sh "scripts/shell/record_video.sh" (:i_url cam) filename (str duration))) 如果我
我有一个保存在scripts /
shell / record_video.sh中的shell脚本,我需要在我的一个项目中调用它.
它在代码中使用的一个例子: (defn save-mp4 [cam filename duration] (sh "scripts/shell/record_video.sh" (:i_url cam) filename (str duration))) 如果我上传到clojars,我将如何jar项目以便包含shell脚本? 跟进 谢谢@Ankur. (sh“bash”:在bash-command-string中)非常有用.我首先需要.sh文件的唯一原因是因为当stdout包含大的东西(比如视频)时,我无法弄清楚如何进行重定向. 文件scripts / shell / record_video.sh包含: 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 我不知道如何翻译重定向(>)而不会使程序内存消耗巨大. (sh“bash”:在bash-command-string中)命令允许在没有shell脚本的情况下编写我的函数: (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))) 解决方法
两个步骤:
>将shell脚本打包为资源. 其中file str是使用资源API读取的shell脚本内容. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |