[Wtr-general] How do I write to simple file instead of screen?

Željko Filipin zeljko.filipin at gmail.com
Tue Nov 28 04:05:06 EST 2006


You can redirect output of your script to file really easy. Go to command
prompt, and write

test.rb > test.txt

That will execute your test.rb script and write output to test.txt file.

A little bit complicated is writing to file from ruby.

file = File.open("test.txt", "w")
file.puts "some text"
file.close

More information:

http://www.rubycentral.com/book/tut_io.html
http://www.ruby-doc.org/core/classes/File.html

There is even ruby logger:

http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/
-- 
Zeljko Filipin
zeljkofilipin.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20061128/6e1dcad2/attachment.html 


More information about the Wtr-general mailing list