Shell program

S

Sky Yin

Hi, rubyists

I'm using system() to execute a shell program under Windows. I wonder
how I can get the result of the external program as a string, since
the system() returns either true or false. I also try to use the Dos
pipeline to save the result to a file, but it doesn't work like this:
system(" program.exe >result.txt"). I can't find anything to explain
why in ruby document. Anyone can help me a bit?

Thanks,

Sky
 
B

Bill Kelly

From: "Sky Yin said:
I'm using system() to execute a shell program under Windows. I wonder
how I can get the result of the external program as a string, since
the system() returns either true or false.

string = `program.exe`


(See also: IO.popen for another way.)


Hope this helps,

Bill
 

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,786
Messages
2,569,625
Members
45,322
Latest member
ClaritaMcI

Latest Threads

Top