From: Shaun Paul on
Hello

I am fetching some data from windows using a simple ruby script using
system command, which is outputting the data onto STDOUT. But I need the
same to get dumped to a local variable.
how can I acheive this? the code snippet I am using is as below

result = system("D:\\softwares\\devcon.exe find *")

This lists out all the devices in device manager onto STDOUT and returns
a 'true' to the variable result. How do I capture the actual data to the
variabel result instead?

Thanks
Shaun
--
Posted via http://www.ruby-forum.com/.

From: Jean-Julien Fleck on
Hello Shaun,

> I am fetching some data from windows using a simple ruby script using
> system command, which is outputting the data onto STDOUT. But I need the
> same to get dumped to a local variable.
> how can I acheive this? the code snippet I am using is as below
>
> result = system("D:\\softwares\\devcon.exe find *")

If it works on windows as it does on Mac and Linux, you just have to
use backsticks:

result = `D:\\softwares\\devcon.exe find *`

You could also look at IO.popen to get a bit more flexibility.

Cheers,

--
JJ Fleck
PCSI1 Lycée Kléber

 | 
Pages: 1
Prev: [ANN] kramdown 0.10.0 released
Next: unsubscribe