Forum: Ruby on Rails Calling System on winows batch file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
640f3ccd1c6308ccdf46950d0d4ae140?d=identicon&s=25 Ryan Mckenzie (mckenzie)
on 2009-01-06 17:07
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.
Ed437e52d8d6720308720e7e678f3e6d?d=identicon&s=25 Patrick Doyle (Guest)
on 2009-01-06 17:38
(Received via mailing list)
On Tue, Jan 6, 2009 at 11:07 AM, Ryan Mckenzie <
rails-mailing-list@andreas-s.net> wrote:

>
> 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
34a7615f38496a5dafbb3e6b721c435e?d=identicon&s=25 Mohit Sindhwani (Guest)
on 2009-01-06 17:42
(Received via mailing list)
Ryan Mckenzie wrote:
> 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.
640f3ccd1c6308ccdf46950d0d4ae140?d=identicon&s=25 Ryan Mckenzie (mckenzie)
on 2009-01-06 21:59
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
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2009-01-06 22:02
(Received via mailing list)
Ryan -
On 6-Jan-09, at 3:59 PM, Ryan Mckenzie wrote:

> 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

likely env issue - echo the path in the bat file.

you might need to set the path correctly @ the top

J
640f3ccd1c6308ccdf46950d0d4ae140?d=identicon&s=25 Ryan Mckenzie (mckenzie)
on 2009-01-06 23:16
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
640f3ccd1c6308ccdf46950d0d4ae140?d=identicon&s=25 Ryan Mckenzie (mckenzie)
on 2009-01-06 23:18
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
This topic is locked and can not be replied to.