I have the rake tasks in my rails application. i want to run a commandline commands with in rake task. how can i do this. i tried by the following but fails
desc "Sending the newsletter to all the users"
task :sending_mail do
run "cd #{RAILS_ROOT} && ar_sendmail -o -t NewsLetters -v"
system "cd #{RAILS_ROOT} && ar_sendmail -o -t NewsLetters -v &"
end
The above run command throws run method undefined & System command not throwing any errors but not executed.
#sh
. It has the shortcoming of using/bin/sh
, not bash however.To use bash from Rake'ssh
method, see this answer to a duplicate question: #9796528 – Walther