Calling System on winows batch file

Hello everyone,

I'm using InstantRails 2.0 on a Windows XP 32 bit system.

I'm developing a Rails application where I would like to execute a .bat file

I've had a look around and this piece of code is suppose to do the trick but it does not seem to work.

system('path/to/file.bat')

Do I need to have some plugins/gems installed?

Regards,

McKenzie.

Hello everyone,

I’m using InstantRails 2.0 on a Windows XP 32 bit system.

I’m developing a Rails application where I would like to execute a .bat

file

I’ve had a look around and this piece of code is suppose to do the trick

but it does not seem to work.

system(‘path/to/file.bat’)

Do I need to have some plugins/gems installed?

Regards,

McKenzie.

No, the #system method is built into Ruby.

Can you execute your #system call from the Rails console? $ script/console

system(“/full/path/to/file.bat”) …works for me.

–wpd

Ryan Mckenzie wrote:

Hello everyone,

I'm using InstantRails 2.0 on a Windows XP 32 bit system.

I'm developing a Rails application where I would like to execute a .bat file

I've had a look around and this piece of code is suppose to do the trick but it does not seem to work.

system('path/to/file.bat')   

Should not need anything special. How do you know it doesn't work? Also, are you using forward slashes in the path? That may not work. Are there spaces in the path to file.bat? That may not work.

Cheers, Mohit. 1/7/2009 | 12:41 AM.

Hi guys, Thanks for your input. I tried using the console and it seems that ruby does not like the content that is in the .bat file for some reason (but the command does work).

The bat file contains this line of text which executes a .exe file to open along with the default.ard file as being a model with the other parameters

resOp default.ard maxcutset="10" outputtype="XML"

If I double click the bat file from windows explorer it runs fine for some reason? Any ideas?

Thanks again, McKenzie

Ryan -

I put in the absolute paths and the bat file executes now but the .exe file displays an output in a new Internet Explorer window. I'm not sure if there is a problem within the .exe file with the .default.ard path being absolute.

How would I echo the path in the bat file? Sorry I'm not very firmilar with it.

Thanks

Ryan Mckenzie wrote:

I put in the absolute paths and the bat file executes now but the .exe file displays an output in a new Internet Explorer window.

Sorry this blank output is different from the expected outcome... the .exe file produces an output file which is then rendered in the Internet Explorer