Ruby 如何在 Rails 执行 Linux 的命令

Thomastar · May 29, 2018 · Last by tkvern replied at June 29, 2018 · 2165 hits

如何在 rails 执行 linux 的命令

现在问题: linux 命令:ffmpeg -i 1.mp4 -y -f image2 -t 0.001 -s 352x240 a.jpg 如何在 rails 执行

一般使用

system('ffmpeg -i 1.mp4 -y -f image2 -t 0.001 -s 352x240 a.jpg')

`ffmpeg -i 1.mp4 -y -f image2 -t 0.001 -s 352x240 a.jpg`

即可

我更倾向于这种做法

谢谢了,原来是 docker 导致..谢谢各位

虽然直接执行命令是可以,但建议最好别这么干。 一种可行的方案是把要执行的命令写到 shell 脚本里面,限定执行的命令参数,代码传入参数调用 shell 脚本。

You need to Sign in before reply, if you don't have an account, please Sign up first.