# Advice in rake

**URL:** <https://www.ruby-forum.com/t/advice-in-rake/166269>\
**Category:** Ruby\
**Created:** [April 23, 2009, 10:57am UTC](https://www.ruby-forum.com/t/advice-in-rake/166269 "2009-04-23T10:57:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 23, 2009, 10:57am UTC](https://www.ruby-forum.com/t/advice-in-rake/166269/1 "2009-04-23T10:57:52Z")

</div>

Hi,

I’m using rake to build a project and during this build process to  
call some scripts as well.  
The problem is now, that the number of required script runs is unknown  
to rake prior to starting rake,  
but can be determined after running the script once. So I’d like to  
use the output of the first runto optionally call  
the task again. What is the best way doing this?

Alternatively I could give a command line option to rake telling it  
how often to run the task. I had the idea  
of putting the number of runs behind the task name, like “run2”,  
“run1”,…  
This will require a dynamic detection in the rake file to separate the  
actual task name “task” from the number of calls.  
Is this possible?

I tried to call the task multiple times in the command line, “rake  
task task task”, but this executes it only once.

Thanks  
Peter

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 23, 2009, 11:37am UTC](https://www.ruby-forum.com/t/advice-in-rake/166269/2 "2009-04-23T11:37:47Z")

</div>

Rakefile:  
desc ‘Task that runs the build and other scripts’  
task :build do  
number\_of\_runs = ( ENV[‘RUN’] ? ENV[‘RUN’] : 1 )  
number\_of\_runs.times do  
# Call whatever  
end  
end

Then in command line:  
$ rake task RUN=2

2009/4/23 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
