Ruby on rails 在Rails中通过shell命令写入本地文件
我正在尝试通过Rails中的shell命令编写文件 基本上我有:Ruby on rails 在Rails中通过shell命令写入本地文件,ruby-on-rails,bash,shell,Ruby On Rails,Bash,Shell,我正在尝试通过Rails中的shell命令编写文件 基本上我有: def self.collect_videos %x[cd public/videos/ && exec viddl-rb http://www.youtube.com/watch?v=oHg5SJYRHA0] sleep(30) end viddl本质上是这样的: 它仅在rails控制台中工作正常,但在rails应用程序中作为函数调用时却无法正常工作 如何修复它?多亏了Mattias Wadma
def self.collect_videos
%x[cd public/videos/ && exec viddl-rb http://www.youtube.com/watch?v=oHg5SJYRHA0]
sleep(30)
end
viddl本质上是这样的:
它仅在rails控制台中工作正常,但在rails应用程序中作为函数调用时却无法正常工作
如何修复它?多亏了Mattias Wadman,这个问题才得以解决。无法将评论标记为答案。如果将cd public/videos/更改为绝对url,会发生什么情况?e、 g./home/ubuntu/app/current/public/videos不工作。。在控制台中工作,但功能不一样当作为应用程序运行时,viddl rb是否在路径中?尝试完整路径。提示是执行…命令…>2> &1>/tmp/log,以便查看发生了什么。还有为什么要使用exec和sleep?在我将绝对路径添加到viddl rb之后,一切都正常了。谢谢你的帮助!