Calling RoR from command line


I’m calling a script from the command line using script/runner. The
script registers some files which are manipulated using ImageMagick’s
tools. The script uses today’s date to scan a directory. Sometimes I
need to scan a directory which dates two-three days back. I tried to
use the following code which does not work:

time =
@date = time.strftime("%Y-%m-%d") unless @date = ARGV[0]

In this case the script won’t insert records in the db. I had to
change the line to:

@date = time.strftime("%Y-%m-%d")

This is fine as long as I don’t have to register orders in the past.
The script is called from crontab using:

ruby ./script/runner -e production ‘require “./register_orders.rb”’

I tried to do a ‘register_orders.rb 2006-02-28’ so ARGV[0] would
become the date. But this prevents register_orders.rb from inserting
any records, regardless of the code above.

Is there any way that I can pass a parameter using script/runner
‘require “my_script param1”’? Or by some other means call it and point
to a date in the past?


On Mar 2, 2006, at 10:30, Claus G. wrote:

ruby ./script/runner -e production ‘require “./register_orders.rb”’

Why there’s no way to pass a script directly to runner?