Running phantomjs from a Ruby on Rails application

二次信任 提交于 2019-12-03 07:50:27

问题


I'm interested in using Phantomjs and I'd like to run it from my Ruby on Rails application. However, this is a command line tool (i.e. I'd need to run something like phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png in my terminal). How would I execute a command line tool from my app?


回答1:


Use backticks in your ruby code e.g.:

output = `phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png`


来源:https://stackoverflow.com/questions/6443945/running-phantomjs-from-a-ruby-on-rails-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!