0

I want to execute an .exe file and get its result as a string to display in my application. How can I do this in ruby?

sawa
  • 165,429
  • 45
  • 277
  • 381
jayashri
  • 9
  • 1

1 Answers1

2

Ruby has several ways of executing other apps in a sub-shell. The easiest is to use back-ticks to wrap the command:

`dir`

will create a sub-shell and execute the dir command in it, then return the STDOUT output to Ruby. You can capture the output by assigning it to a variable:

output = `dir`
the Tin Man
  • 158,662
  • 42
  • 215
  • 303