redirection Windows shell out to variable

B

born in USSR

i want to execute Windows shell commands in my script so that the result
came back in a variable and the new window of a Windows command line
(MS-DOS-session) didn't open.
i write:
a='dir'
system(a)
and i see out of 'dir' in window of command line, but i need to get it
into local variable.
And another question:
every time when rubyscript was run command line window is opening, even
if i compile script by exerb. Is it possible to hide window or run
script/rubyexefile without command line window and how if yes?
 
S

Sven Schott

[Note: parts of this message were removed to make it a legal post.]

You can use the backtick (or backquote) operator ` which is ASCII character
96:

e.g.

a = `dir`

which will give you a string with the stdout of the executed shell. Not that
I would recommend using it with dir mind you. :)
 
G

Gordon Thiesfeld

And another question:
every time when rubyscript was run command line window is opening, even
if i compile script by exerb. Is it possible to hide window or run
script/rubyexefile without command line window and how if yes?

Run it with rubyw.exe, instead of ruby.exe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top