execute shell command in ruby rake task
There are a few differnt options to execute shell cmd in ruby rake task:
1. exec
2. system
3. backtick “
4. %x{}
%x{} returns back to rake task whereas exec and system does not (exec replace the current process with a new one, system return true or false )
so if you do something like
desc 'example' task :example do exec {cmd_one} exec {cmd_two} end end
cmd two will never get executed. Switch to %x{} instead.
btw, you can run multiple rake task like this
desc 'example' task :example do Rake::Task['name_space:task_one'] Rake::Task['name_space:task_two'] end end
Thanks Eric! That’s exactly what I was looking for.
michal kuklis
July 27, 2009 at 9:19 pm