使用Ruby on Rails执行脚本? [英] Execute script with Ruby on Rails?
问题描述
我想用我的应用程序启动我的守护进程。
I want to start my daemon with my application.
在命令行中,我可以写入 lib / daemons / mydaemon_ctl start
启动我的守护进程,但我必须手动这样做。我想让守护进程启动时,我启动我的服务器(即当初始化文件加载时)。
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).
有一个ruby命令执行命令行吗?
像 execlib / daemons / mydaemon_ctl start
?
Is there a ruby command for executing a command line?
Something like exec "lib/daemons/mydaemon_ctl start"
?
谢谢!
推荐答案
似乎你只想在ruby代码中运行shell命令,你可以使用系统或反引号
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
这篇关于使用Ruby on Rails执行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!