From: Mark Pelletier Date: 2007-09-22T00:15:44+09:00 Subject: Re: cgi scripts don't know hostname It turns out that the cgi scripts run this way have an empty or at least incomplete ENV. I worked around it by marshaling the server's ENV and having the cgi's read it at startup. Not a great solution, but it works. Mark Pelletier wrote: > Forgive me if this is a dumb question, but it's got me stumped. > > I'm running a WEBrick server and I've mounted HTTPServlet::FileHandler > as follows: > > s.mount("/cgi-bin",HTTPServlet::FileHandler, > cgi_dir,{:FancyIndexing=>true}) > > However, the scripts in the cgi-bin directory can't find the hostname > when they're run by the web server. E.g., the following script > > #!/usr/bin/ruby -w > > s = %{ > > > Hi #{ENV['HOSTNAME']} Bye > > > } > print s > > prints the html with the machine name embedded in it when I run it from > the command line, but only "Hi Bye" when I look at it in the browser. > What's up with that? -- Posted via http://www.ruby-forum.com/.