Guys, I have InstantRails in my PC. i have written a ruby programm which will copy a file from my document to rails private directory varifying some characteristic of files.Suppose ruby directory is c:/instantsRails/ruby/bin/ruby.exe and my file is in c:/myfile.rb . so how can i create a bat file which can run ruby and run my file? so that each time when i copy file to upload directory and just click the .bat file and do the job. waiting for ur responce. Amin
on 2007-03-01 10:12
on 2007-03-01 13:34
save a text file as blah.bat in the file type ruby myfile.rb save, run and smile :) regards
on 2007-03-01 13:41
Ivor Paul wrote: > save a text file as blah.bat > > in the file type > > ruby myfile.rb > > save, run and smile :) > > regards thanks for ur reply . but I tried it but error was "ruby" command not found. so i guess, i have to first run the ruby.exe and then then run the file by ruby. am I right? if yes then how can I do this? Amin
on 2007-03-01 14:39
I would guess that ruby isn't properly installed...or not installed at all, apart from instantRails. if you type "ruby -v" in a cmd you should get a line telling you which version of ruby you have installed... instantrails contains ruby so that rails applications can run in the instantrails sandbox, but it does not install as a os wide application/service...I'm out of my depth with the vocab. Basically, if you download and install ruby http://rubyforge.org/frs/?group_id=167 it will install and you will be able to run ruby anywhere in a command line.
on 2007-03-01 17:17
Ruhul Amin wrote: > Ivor Paul wrote: >> save a text file as blah.bat >> >> in the file type >> >> ruby myfile.rb >> >> save, run and smile :) >> >> regards > > thanks for ur reply . but I tried it but error was > > "ruby" command not found. > so i guess, i have to first run the ruby.exe and then then run the file > by ruby. > > am I right? if yes then how can I do this? > > > Amin Perhaps the path to your ruby.exe is not included in your PATH environment variable in Windows. If so, either edit your PATH to include it, or else add the full path to the ruby.exe to your batch file: c:\InstantRails\bin\ruby.exe myfile.rb [Your actual path may vary from that shown above]
on 2007-03-01 17:17
On 3/1/07, Ruhul Amin <firstname.lastname@example.org> wrote: > > regards > > thanks for ur reply . but I tried it but error was > > "ruby" command not found. > so i guess, i have to first run the ruby.exe and then then run the file > by ruby. > > am I right? if yes then how can I do this? The problem your are having is because of one of the features of Instant Rails: the fact that it does not modify your system environment. IR's ruby\bin directory is not on your system path (as it would be with a normal Ruby installation). If you don't plan to move IR at all (for example, you don't have it on a flash drive), then the simplest thing would be to put IR's ruby\bin on the path. Another alternative would be to put your bat file in IR's ruby\bin directory and then at runtime use the path to the bat file to construct a path to ruby\bin\ruby.exe. For examples of doing this, look at the bat files already in the ruby\bin directory. Curt
on 2007-03-02 10:22
David wrote: >>> save, run and smile :) >> > [Your actual path may vary from that shown above] > > This should help you, it's from my .bat files that run ruby scripts. Of course, fix the paths to match yours. <code> echo off cls REM Set up the environment variables for the script set PATH_TO_RUBY=D:\InstantRails\ruby\bin set RUBY=%PATH_TO_RUBY%\ruby.exe set PATH_TO_SCRIPTS=F:\Projects\autoscripts %RUBY% %PATH_TO_SCRIPTS%\MyRubyScript1.rb %RUBY% %PATH_TO_SCRIPTS%\MyRubyScript2.rb %RUBY% %PATH_TO_SCRIPTS%\MyRubyScript3.rb </code> If you want it to be something that starts asynchronously (in the sense that it starts in a separate Command window and does not hold up the original .bat file which is starting your script, you could also use: <code> start %RUBY% %PATH_TO_SCRIPTS%\AnotherScript.rb </code> Hope this helps! Cheers Mohit.
on 2007-03-02 14:16
thanks for clarifying that for me as well!