ruby-quiz # 26, wiki served by webrick

A

anne001

http://www.rubyquiz.com/quiz26.html
I tried to do everything as indicated on this post but I get an error:

I have wikiserver.rb in a folder /library/webserver/documents/ruby
--------->
#!/private/opt/local/bin/ruby -rcgi

require "webrick"

server = WEBrick::HTTPServer.new( :port => 8080,
:DocumentRoot => "cgi-bin" )

['INT', 'TERM'].each do |signal|
trap(signal) { server.shutdown }
end
server.start

and wiki.cgi in a folder /library/webserver/documents/ruby/cgi-bin
------------->
#!/private/opt/local/bin/ruby -rcgi

H, B = %w'HomePage w7.cgi?n=%s'

c = CGI.new 'html4'

n, d = c['n'] != '' ? c['n'] : H, c['d']

t = `cat #{n}`

d != '' && `echo #{t = CGI.escapeHTML(d)} > #{n}`

c.instance_eval {
out {
h1 { n } +
a(B % H) { H } +
pre { t.gsub(/([A-Z]\w+){2}/) { a(B % $&) { $& } }
} +
form("get") {
textarea('d') { t } +
hidden('n', n) +
submit
}
}
}

I run ruby wikiserver.rb
then on the safari web browser
http://localhost:8080/wiki.cgi
---------->
ERROR CGIHandler: /Library/WebServer/Documents/ruby/cgi-bin/wiki.cgi:
/opt/local/lib/ruby/1.8/webrick/httpservlet/cgi_runner.rb:45:in `exec':
Exec format error - /Library/WebServer/Documents/ruby/cgi-bin/wiki.cgi
(Errno::ENOEXEC)
from
/opt/local/lib/ruby/1.8/webrick/httpservlet/cgi_runner.rb:45
ERROR CGIHandler: /Library/WebServer/Documents/ruby/cgi-bin/wiki.cgi
exit with 1
ERROR Premature end of script headers:
/Library/WebServer/Documents/ruby/cgi-bin/wiki.cgi
"GET /wiki.cgi HTTP/1.1" 500 363
- -> /wiki.cgi

How do I get this code to work? (using ruby 1.8.4)
 
A

anne001

I was able to run the ruby-quiz #26 wiki, I found the problem, somehow
copying and pasting in emacs, & became &
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top