[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to hide dos prompt?

camenix

11/1/2006 2:40:00 AM

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.

3 Answers

Austin Ziegler

11/1/2006 3:23:00 AM

0

On 10/31/06, camenix <vipeak@gmail.com> 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
--
Austin Ziegler * halostatue@gmail.com * http://www.halo...
* austin@halostatue.ca * http://www.halo...feed/
* austin@zieglers.ca

camenix

11/1/2006 10:56:00 AM

0

On Nov 1, 11:23 am, "Austin Ziegler" <halosta...@gmail.com> 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

camenix

11/1/2006 11:22:00 AM

0

> 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!