Downloadable file "on the fly"

I'd like to have a cgi script produce it's output
as a downloadable .csv file rather than displaying it on screen.
In perl, I used to do it this way:

@stuff = qw(some items in an array);
print $cgi->header(-TYPE => 'text/plain',
                   -EXPIRES => 'now',
                   -ATTACHMENT => 'download.csv');
foreach (@stuff) { print "$_\cI"; }
exit 0;

Any suggestions on doing the same with ruby? A direct translation
of the code doesn't seem to be very effective - I get only a blank
page.
Thanks for any suggestions.

···

--
www.sirwilliamhope.org

Try this (*not tested*)

@stuff = qw(some items in an array);

   stuff = %w(some items in an array)

print $cgi->header(-TYPE => 'text/plain',
                   -EXPIRES => 'now',
                   -ATTACHMENT => 'download.csv');

   puts cgi.header(
      "type" => "text/plain",
      "Date" => Time.now,
      "Expires" => Time.now,
      "Content-Disposition" => 'attachment; filename="download.cvs"')

foreach (@stuff) { print "$_\cI"; }

   puts stuff.join("\t")

Guy Decoux

Try this (*not tested*)

Thanks.

   puts cgi.header(
      "type" => "text/plain",
      "Date" => Time.now,
      "Expires" => Time.now,
      "Content-Disposition" => 'attachment; filename="download.cvs"')

That was the main part that was giving be problems - I'll try it out.
Milo.

···

ts <decoux@moulon.inra.fr> wrote:

--
www.sirwilliamhope.org