How to hide dos prompt?

Hi,
I want to run a ruby script on windows hiding dos prompt ,because
some code come from lib,
I can’t use rubyw.exe to solve this problem.
The question is ,how to hiding dos prompt without deleting all the
“puts”, “print”,“printf” in the code?
what should i do with $stderror and $stdout?
Any idea is welcome.

On 10/31/06, camenix [email protected] wrote:

 I want to run a ruby script on windows hiding dos prompt ,because

some code come from lib,
I can’t use rubyw.exe to solve this problem.
The question is ,how to hiding dos prompt without deleting all the
“puts”, “print”,“printf” in the code?
what should i do with $stderror and $stdout?
Any idea is welcome.

You can only hide the DOS prompt by using rubyw.exe (there’s no
console). You can, however redirect the STDERR and STDOUT (and STDIN,
don’t forget) to either strings or files.

-austin

On Nov 1, 11:23 am, “Austin Z.” [email protected] wrote:

You can only hide the DOS prompt by using rubyw.exe (there’s no
console). You can, however redirect the STDERR and STDOUT (and STDIN,
don’t forget) to either strings or files.

How to redirect ? Is like this:
lib.rb
def hello
puts “hello,world!”
end

main.rb
require ‘lib’
f=open(‘h.txt’,‘w’) # It didn’t work
f.reopen($stdout) # It didn’t work
puts “hi!”
hello

lib.rb
def hello
puts “hello,world!”
end

main.rb
require ‘lib’
$stdout=open(‘h.txt’,‘w’)
$stderr=open(‘h1.txt’,‘w’)
puts “hi!”
hello

It does work!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs