Forum: Ruby Running a script from a rake task?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2b2c2a705ed12f8fb327c7b4c56456c6?d=identicon&s=25 Sean Hussey (seanhussey)
on 2006-02-15 20:55
(Received via mailing list)
Hi everyone,

I have 2 scripts (dbload.rb and import_people.rb) that I want to
include in a rake task.  How can I run an external script in a rake
task?  Do I have to shell out to do it?  Or should I just make those
scripts rake tasks?  For this dev environment, that might not be a bad
thing.

task :cleandb => [:db_schema_import] do
  # Run script/dbload.rb
  # Run script/import_people.rb
end

This is in a Rails environment, but I don't think it's a Rails
specific question, so I'm posting here.

Thank you!

Sean
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-02-15 21:10
(Received via mailing list)
On Feb 15, 2006, at 1:53 PM, Sean Hussey wrote:

> Do I have to shell out to do it?

Try this:

> task :cleandb => [:db_schema_import] do
>   # Run script/dbload.rb

   ruby "script/dbload.rb"

>   # Run script/import_people.rb

   ruby "script/import_people.rb"

> end

Hope that helps.

James Edward Gray II
2b2c2a705ed12f8fb327c7b4c56456c6?d=identicon&s=25 Sean Hussey (seanhussey)
on 2006-02-15 21:28
(Received via mailing list)
Good lord, it's that easy?  Silly me.

Thank you!

Sean
This topic is locked and can not be replied to.