问题
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