Well this is weird! I'm used to odd problems when you run programs from
cron but these are almost invariably to do with file permissions or
stuff in the environment variables not matching the command line
environment.
I'm using ruby 1.8.4 (2005-12-24) [i686-linux] on a RHE 3.0 system.
The program runs fine from command line but gets nonsensical syntax
errors when run from cron.
Any idea where to look for the problem?
Russell
···
--
Posted via http://www.ruby-forum.com/.
probably you have two ruby installations and the wrong one is running your
script.
-a
···
On Mon, 21 Aug 2006, Russell Fulton wrote:
Well this is weird! I'm used to odd problems when you run programs from
cron but these are almost invariably to do with file permissions or
stuff in the environment variables not matching the command line
environment.
I'm using ruby 1.8.4 (2005-12-24) [i686-linux] on a RHE 3.0 system.
The program runs fine from command line but gets nonsensical syntax
errors when run from cron.
Any idea where to look for the problem?
Russell
--
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama
Russell Fulton wrote:
Well this is weird! I'm used to odd problems when you run programs from cron but these are almost invariably to do with file permissions or stuff in the environment variables not matching the command line environment.
I'm using ruby 1.8.4 (2005-12-24) [i686-linux] on a RHE 3.0 system.
The program runs fine from command line but gets nonsensical syntax errors when run from cron.
Any idea where to look for the problem?
What is the user that actually runs the job in cron?
Are you using absolute paths?
#!/usr/local/bin/ruby
not
#!/usr/bin/env ruby
in the script (since env will differ for different users)?
When run from the CLI are there RUBYOPT values (e.g., rubygems) in the environment that are not there for cron?
···
--
James Britt
http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://refreshingcities.org - Design, technology, usability
James Britt wrote:
Russell Fulton wrote:
Any idea where to look for the problem?
What is the user that actually runs the job in cron?
Are you using absolute paths?
#!/usr/local/bin/ruby
not
#!/usr/bin/env ruby
we are getting close here! I've managed to reproduce the error on the
cli by executing the file directly instead of running ruby <filename>
i.e
selms.rb ... dies
whereas
ruby selms.rb ... works fine.
file starts with:
#! /usr/bin/ruby
[rful011@pateke selms]$ ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 3548 Oct 5 2005 /usr/bin/ruby
cron job looks like this:
40 * * * * cd /home/rful011/selms; ruby ./selms.rb -M -o
selms -t periodic log.patterns
note that the script is invoked via ruby in the cron job but gives the
same symptoms as the file being executed directly.
Here is the output from the cron job:
SHELL=/bin/sh
MAILTO=irt@auckland.ac.nz
SHEll=/bin/sh
OLDPWD=/home/logowner
USER=logowner
PATH=/usr/bin:/bin
PWD=/home/rful011/selms
SHLVL=1
HOME=/home/logowner
LOGNAME=logowner
_=/usr/bin/env
./selms.rb:55: syntax error
when 'periodic' : Periodic.new( conf, $options[:syntax])
^
./selms.rb:56: syntax error
when 'realtime' :
^
···
--
Posted via http://www.ruby-forum.com/.
you have 1.8.4 installed in one place, probably /usr/local/bin/ and 1.6.8 in
/usr/bin
type
which -a ruby
and
/usr/bin/ruby -v
/usr/local/bin/ruby -v
probably you should change the shebang line in your script. alternately you
can set the PATH in your crontab like so
PATH=/usr/local/bin:$PATH
regards.
-a
···
On Mon, 21 Aug 2006, Russell Fulton wrote:
James Britt wrote:
Russell Fulton wrote:
Any idea where to look for the problem?
What is the user that actually runs the job in cron?
Are you using absolute paths?
#!/usr/local/bin/ruby
not
#!/usr/bin/env ruby
we are getting close here! I've managed to reproduce the error on the
cli by executing the file directly instead of running ruby <filename>
i.e
selms.rb ... dies
whereas
ruby selms.rb ... works fine.
file starts with:
#! /usr/bin/ruby
--
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama
unknown wrote:
file starts with:
#! /usr/bin/ruby
you have 1.8.4 installed in one place, probably /usr/local/bin/ and
1.6.8 in
Bugger! you're dead right!
[rful011@pateke selms]$ whereis ruby
ruby: /usr/bin/ruby /usr/lib/ruby /usr/local/bin/ruby
/usr/local/lib/ruby /usr/share/man/man1/ruby.1.gz
[rful011@pateke selms]$ ls -l /usr/local/bin/ruby
-rwxr-xr-x 1 root root 1214420 Jul 24 16:28
/usr/local/bin/ruby
I was using darwin ports on a mac to install FreeRide and aborted it
when I realised it was installing its copy of Ruby. I though I had got
rid of it, but clearly not!
Now I'll figure out why 1.8.4 is generating syntax errors.
Thank you very much!
···
On Mon, 21 Aug 2006, Russell Fulton wrote:
--
Posted via http://www.ruby-forum.com/.