From: g_f <8si.greg@...> Date: 2009-08-20T07:37:04+09:00 Subject: Re: when run from cron, regex NEVER match, always give nil Like Tim said, it's probably something in the environment. Besides PATH, you could have other environment variables set in your BASH startup that are not set when the default /bin/sh gets started. For apps I have to run from cron, if I need to, I'll write a wrapping .sh script that sets up the environment exactly as I need it. That could include switching to bash/csh/zsh or whatever, or sourcing .login or .profile or manually setting variables. Cron is stupid and does exactly what is said plus whatever (hidden) defaults the system has set up, so figuring it out can be a real task. I wonder if you might have installed some libraries in your own space instead of the system's Ruby space. User permission problems will crop up then and can be a pain to figure out. I'd debug that by logging in as whatever user the cron job runs as, then manually run the script. You don't say whether your job is running out of your own user's cron, or out of root's cron, or via the system's /etc/crontab. For my production code I set up the scripts to be run as root, but that's because I've been doing this so long I've shot off most of my toes and learned the hard lessons about what not to do... I'm sufficiently paranoid so I'm considered a trusted user. :-) On Aug 18, 5:52 pm, James Dinkel wrote: > I'm using ruby 1.8.6 on RHEL 5.3. I also had this problem with ruby > 1.8.5 that comes with RHEL. I had hoped the ruby upgrade would fix it > but it didn't. > > Anyway, no regexps will match, even the most blatant matches, when the > script is run from cron. > > A line like '/.*/.match("myrandomstring")' matches just fine when the > script is run from the console, but it returns nil when run from cron. > And that regex should match ANYTHING. > > I'm not sure if this is an issue with ruby or if it is something with > cron, but I really need regex's to work from cron scripts.  Help? > -- > Posted viahttp://www.ruby-forum.com/.