cgi scripts don't know hostname

M

Mark Pelletier

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 = %{
<html>
<body>
Hi #{ENV['HOSTNAME']} Bye
</body>
</html>
}
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?
 
M

Mark Pelletier

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 said:
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 = %{
<html>
<body>
Hi #{ENV['HOSTNAME']} Bye
</body>
</html>
}
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?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top