Forum: Ruby on Rails calling RoR from command line

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Claus G. (Guest)
on 2006-03-02 11:30
(Received via mailing list)

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?

Xavier N. (Guest)
on 2006-03-02 12:32
(Received via mailing list)
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?
This topic is locked and can not be replied to.