Forum: Ruby on Rails calling RoR from command line

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.
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-03-02 10:30
(Received via mailing list)
Hi.

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 = Time.now
@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?

regards
Claus
7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2006-03-02 11:32
(Received via mailing list)
On Mar 2, 2006, at 10:30, Claus Guttesen 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.