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( ort => 8080,
ocumentRoot => "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)
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( ort => 8080,
ocumentRoot => "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)