Re: Windows: Scheduled Ruby script won't run



bdezonia@xxxxxxxx wrote:
Hello all,

I have looked on the web for an answer to my issue with little success
so I am trying here. I have a ruby script that I am scheduling at
computer startup on Windows. And apparently it never starts. If it
starts it should write a line to a file. From the command prompt the
script works fine but if logged in and attempting to start it from
Scheduled Tasks it fails too with no error messages or any evidence it
tried to start. I've checked account and password info for the task
and it is correct. In fact I've tried to different admin acounts
(though from a parent account). Is there something about the
environment maybe not being loaded since its not run from a shell that
is the problem? Any other ideas? Thanks for your insight.


The most common problem is the path. I usually bootstrap my Ruby script
using a .cmd file that sets the path to my Ruby interpreter and then
calls the interpreter with the name of the script. It's always worked
for me. Also, if for some reason, you don't trust the Windows
scheduler, you could use PyCron - it's a cron replacement on Windows
that works very well (specially recommended if you plan to schedule the
script more frequently than just system startup).

This is what I use in my scripts:

REM Set up the environment variables for the script
set PATH_TO_RUBY=d:\InstantRails\ruby\bin
set RUBY=%PATH_TO_RUBY%\ruby.exe

REM ** settings for accessing the remaining scripts **
set PATH_TO_SCRIPTS=X:\Projects\scripts

%RUBY% %PATH_TO_SCRIPTS%\my_script.rb

Hope this helps.

Cheers,
Mohit.
11/8/2007 | 2:47 AM.




.



Relevant Pages

  • Re: Scheduled task onlogon monthly?
    ... This page includes a link for a free download of Windows Script ... simple programs to facilitate some special scheduling needs. ... into standby before my all of my scheduled jobs can run. ...
    (microsoft.public.windowsxp.general)
  • How to coloring Windows command prompt in irb?
    ... Is there any gem or ruby script to make irb command prompt in windows ... It can't work in cygwin or windows command prompt. ...
    (comp.lang.ruby)
  • RE: simple shell script
    ... here is a ruby script that I found ... did we clobber all the args? ...
    (freebsd-questions)
  • [Dialog] Cracking Richard
    ... Oliver has recently published a ruby script that works well for Dialog ... users interested in archiving messages. ... # extract all Sent messgages from all msg*.dat in Dialog's data direectory ...
    (news.software.readers)
  • Re: RubyScript2Exe 0.4.3
    ... That would depend on what libraries your script requires... ... Erik Veenstra wrote: ... RubyScript2Exe transforms your Ruby script into a standalone, ... result is the same: a standalone executable. ...
    (comp.lang.ruby)