From: Anatol Pomozov Date: 2006-07-16T15:54:20+09:00 Subject: Re: system() on windows Logan Capaldo wrote: > On Jul 15, 2006, at 10:12 PM, brad tilley wrote: > >> I want to capture the string that system("hostname") produces on >> windows >> and store it in a variable. system() returns true or false. How can I >> make it return the result (the hostname as a string) instead? >> >> -- >> Posted via http://www.ruby-forum.com/. >> > > Use backticks: > > hostname = `hostname`.chomp If you want to catch all output including both STDOUT and STDERR you should do following trick output = `someprogram 2>&1` So using OS pipes you redirect STDERR to STDOUT and then run application and get STDOUT using `` function. -- Posted via http://www.ruby-forum.com/.