Execute script with Ruby on Rails?

爷,独闯天下 提交于 2019-12-25 14:25:13

问题


I want to start my daemon with my application.

In the command line, I can write something like lib/daemons/mydaemon_ctl start to start up my daemon, but I have to do this manually. I want the daemon to start when I start my server (i.e. when the initializer files are loaded).

Is there a ruby command for executing a command line? Something like exec "lib/daemons/mydaemon_ctl start"?

Thanks!


回答1:


Seems you just want to run shell commands in ruby code, well you can use system or backtick(`)

system 'ls' # will return ls output in *nix
`dir` # will return dir output in windows


来源:https://stackoverflow.com/questions/2947180/execute-script-with-ruby-on-rails

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