From: Justin Collins Date: 2011-02-23T15:50:27+09:00 Subject: Re: Show text from text file in cgi script On 02/22/2011 06:27 PM, Ryan C. wrote: > I am writing a cgi script to pull the contents of a .txt file in the > cgi-bin directory into the body of an html file and can't seem to figure > it out. > > eruby seems to be a solution, but I can't tell if it's to be used with > Rails or not and the documentation is lacking for a newbie. > > Here's what I've got: > > [code] > #!/usr/local/bin/ruby > # SCRIPT hello_world.cgi > # CREATOR: Ryan Clark > puts "Content-type: text/html" > puts > > #This line left intentionally blank > > puts< > > > Oliver Twist > > > > <% File.open("oliver_twist.txt").each { |line| puts line } %> > > > HTML > [/code You are not actually using eruby in your script, but you are trying to use the eruby syntax, which is not needed. When you are using "here documents," you are just using big multiline strings, meaning you can use string interpolation to insert the contents of the file into the middle of the string. For example: x = "world" puts <