[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

cannot execute ruby files without wrapper in a cron

Junkone

1/6/2008 9:28:00 PM

whenever i try to execute a ruby file thro cron, i have to write a
crapper to cd the folder of the ruby file and then execute it. it is
such a hassle. what are the alternatives so that i dont have to write
a wrapper. the prob that i get if i run them directly is that it tries
to run in the same directory of the cron and cannot find the local
libraries that my require statments have. how can i get ruby to
execute the rb file in a specific directory. or is there any other
option.

RUBY E:\TradingTools\CODE\ABScans.rb
e:/ruby/lib/ruby/site_ruby/1.8/xmlconfigfile.rb:646: warning:
parenthesize argum
ent(s) for future version
e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_re
quire': no such file to load -- sendGmail (LoadError)
from e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `re
quire'
from E:/TradingTools/CODE/ABScans.rb:3

2 Answers

Robert Dober

1/6/2008 10:17:00 PM

0

On Jan 6, 2008 10:29 PM, Junkone <junkone1@gmail.com> wrote:
> whenever i try to execute a ruby file thro cron, i have to write a
> crapper to cd the folder of the ruby file and then execute it. it is
> such a hassle. what are the alternatives so that i dont have to write
> a wrapper. the prob that i get if i run them directly is that it tries
> to run in the same directory of the cron and cannot find the local
> libraries that my require statments have. how can i get ruby to
> execute the rb file in a specific directory. or is there any other
> option.
>
> RUBY E:\TradingTools\CODE\ABScans.rb
> e:/ruby/lib/ruby/site_ruby/1.8/xmlconfigfile.rb:646: warning:
> parenthesize argum
> ent(s) for future version
> e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `gem_original_re
> quire': no such file to load -- sendGmail (LoadError)
> from e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 27:in `re
> quire'
> from E:/TradingTools/CODE/ABScans.rb:3
>
>
>

571/72 > ruby -h
Usage: ruby [switches] [--] [programfile] [arguments]
-0[octal] specify record separator (\0, if no argument)
-a autosplit mode with -n or -p (splits $_ into $F)
-c check syntax only
-Cdirectory cd to directory, before executing your script
-d set debugging flags (set $DEBUG to true)
-e 'command' one line of script. Several -e's allowed. Omit [programfile]
-Fpattern split() pattern for autosplit (-a)
-i[extension] edit ARGV files in place (make backup if extension supplied)
-Idirectory specify $LOAD_PATH directory (may be used more than once)
-Kkcode specifies KANJI (Japanese) code-set
-l enable line ending processing
-n assume 'while gets(); ... end' loop around your script
-p assume loop like -n but print line also like sed
-rlibrary require the library, before executing your script
-s enable some switch parsing for switches after script name
-S look for the script using PATH environment variable
-T[level] turn on tainting checks
-v print version number, then turn on verbose mode
-w turn warnings on for your script
-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)
-x[directory] strip off text before #!ruby line and perhaps cd to directory
--copyright print the copyright
--version print the version

I guess the -I (that is "i".upcase) is the option you need, AAMOF cron
jobs are not exactly executed as in a login shell, I ignore(1) the
details, but man cron will explain this in detail.
Just for curiosity, which cron are you using and in which context (cygwin?).

HTH
Robert
(1) keep forgetting them is more precise ;)

--
http://ruby-smalltalk.blo...

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein

Junkone

1/6/2008 11:56:00 PM

0

On Jan 6, 5:16 pm, Robert Dober <robert.do...@gmail.com> wrote:
> On Jan 6, 2008 10:29 PM, Junkone <junko...@gmail.com> wrote:
>
>
>
>
>
> > whenever i try to execute a ruby file thro cron, i have to write a
> > crapper to cd the folder of the ruby file and then execute it. it is
> > such a hassle. what are the alternatives so that i dont have to write
> > a wrapper. the prob that i get if i run them directly is that it tries
> > to run in the same directory of the cron and cannot find the local
> > libraries that my require statments have. how can i get ruby to
> > execute the rb file in a specific directory. or is there any other
> > option.
>
> > RUBY E:\TradingTools\CODE\ABScans.rb
> > e:/ruby/lib/ruby/site_ruby/1.8/xmlconfigfile.rb:646: warning:
> > parenthesize argum
> > ent(s) for future version
> > e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `gem_original_re
> > quire': no such file to load -- sendGmail (LoadError)
> >         from e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> > 27:in `re
> > quire'
> >         from E:/TradingTools/CODE/ABScans.rb:3
>
> 571/72 > ruby -h
> Usage: ruby [switches] [--] [programfile] [arguments]
>   -0[octal]       specify record separator (\0, if no argument)
>   -a              autosplit mode with -n or -p (splits $_ into $F)
>   -c              check syntax only
>   -Cdirectory     cd to directory, before executing your script
>   -d              set debugging flags (set $DEBUG to true)
>   -e 'command'    one line of script. Several -e's allowed. Omit [programfile]
>   -Fpattern       split() pattern for autosplit (-a)
>   -i[extension]   edit ARGV files in place (make backup if extension supplied)
>   -Idirectory     specify $LOAD_PATH directory (may be used more than once)
>   -Kkcode         specifies KANJI (Japanese) code-set
>   -l              enable line ending processing
>   -n              assume 'while gets(); ... end' loop around your script
>   -p              assume loop like -n but print line also like sed
>   -rlibrary       require the library, before executing your script
>   -s              enable some switch parsing for switches after script name
>   -S              look for the script using PATH environment variable
>   -T[level]       turn on tainting checks
>   -v              print version number, then turn on verbose mode
>   -w              turn warnings on for your script
>   -W[level]       set warning level; 0=silence, 1=medium, 2=verbose (default)
>   -x[directory]   strip off text before #!ruby line and perhaps cd to directory
>   --copyright     print the copyright
>   --version       print the version
>
> I guess the -I (that is "i".upcase) is the option you need, AAMOF cron
> jobs are not exactly executed as in a login shell, I ignore(1) the
> details, but man cron will explain this in detail.
> Just for curiosity, which cron are you using and in which context (cygwin?).
>
> HTH
> Robert
> (1) keep forgetting them is more precise ;)
>
> --http://ruby-smalltalk.blo...
>
> ---
> Whereof one cannot speak, thereof one must be silent.
> Ludwig Wittgenstein- Hide quoted text -
>
> - Show quoted text -

I am using python cron on windows and -I is just what the doc
prescribed. its works beautifully.