From: 7stud -- Date: 2009-05-10T02:47:15+09:00 Subject: Re: CGI help Jeff Leggett wrote: > 7stud -- wrote: >> Jeff Leggett wrote: >>> output = cgi.html do >>> cgi.head { cgi.title { TITLE } } + >>> cgi.body { cgi.h1 { TITLE } } + >> How about getting rid of.........^ ? > > I changed it like that, EXACT same errors. I have matched up the 'ends' > and bracket more times than I can count now, even slept on it, thinking > my tired brain would see it right off this morning, but no... Thanks for > your help though guys... > > #!/usr/bin/ruby > > require "cgi" > > Filename = 'classification.txt' > > EMPTY_STRING = '' > TITLE = 'Vulnerability Classification' > cgi = CGI.new('html4') > output = cgi.html do > cgi.head { cgi.title { TITLE } } + > cgi.body { cgi.h1 { TITLE } + > cgi.form('post') do > if File.readable?(Filename) then > f = File.open(Filename,"r") > f.each_line { |l| l.chomp > inputs = l.split(',') > puts inputs[0].to_s + ": " > opts = "\"" + inputs[1].to_s + "\"" > 2.times { inputs.delete_at(0) } > until inputs.empty? do > opts = opts + "[\"" + inputs[1].to_s + "\",\"" + > inputs[0].to_s + "\"]" > 2.times { inputs.delete_at(0) } > end > cgi.popup_menu(opts) + > cgi.br + > } > f.close > end > cgi.submit > end > } > end > cgi.out { output.gsub('><', ">\n<") } > > [jleggett@binford cgi-bin]$ ./vuln.rb > ./vuln.rb:27: syntax error > ./vuln.rb:29: syntax error > end > ^ > ./vuln.rb:31: syntax error > end > ^ > ./vuln.rb:38: syntax error > [jleggett@binford cgi-bin]$ Putting these lines: cgi.popup_menu(opts) + cgi.br + inside the if statement doesn't work for me: I get a bunch of kEND errors. If I move those lines outside the if statement, then no errors: cgi = CGI.new('html4') output = cgi.html { cgi.head { cgi.title { TITLE } } + cgi.body { cgi.h1 { TITLE } + cgi.form('post') { if File.readable?(Filename) f = File.open(Filename,"r") opts = "" f.each_line do |l| l.chomp #does nothing inputs = l.split(',') puts inputs[0].to_s + ": " opts << "\"" + inputs[1].to_s + "\"" 2.times { inputs.delete_at(0) } until inputs.empty? opts << "[\"" + inputs[1].to_s + "\",\"" + inputs[0].to_s + "\"]" 2.times { inputs.delete_at(0) } end end #each_line f.close end #if cgi.popup_menu(opts) + cgi.br + cgi.submit } #form } #cgi.body } #cgi.html cgi.out { output.gsub('><', ">\n<") } I have no idea why that is the case. -- Posted via http://www.ruby-forum.com/.