Hello,

I use <perl> sections quite intensively to configure my apache server.
I would like to build in some user interaction during startup.

For this I added the following code to my httpd.conf:
(I omitted the non relevant parts)

<perl>
# We need a couple of modules, which we load here.

   use Sys::Hostname;
   use Apache2::PerlSections();
   use Socket;
   use Term::ReadKey;
 #  we need to be able to switch e between int and test
                       print STDOUT "To which environment should
requests  be forwarded?\n";
                       print STDOUT "(i)nt\n";
                       print STDOUT "(t)est\n";
                       print STDOUT "You have 5 seconds to answer,
after which the default (int) will be activated\n";
                       ReadMode("noecho");
                       while (1) {
                               my $key;
                               $key = ReadKey(5,STDIN);
                               if ($key) {
                                       if ( $key eq "i" ) {
                                               $forwardTo = "intserver" ;
                                               last;
                                       } elsif ( $key eq "t" ) {
                                               $forwardTo = "testserver" ;
                                               last;
                                       } else {
                                               print STDOUT "please
press i or t \n";
                                       }
                               } else {
                                       print STDOUT "You didn't make
a choice, so we go with the default.\n";
                                       $forwardTo = "intserver";
                                       last;
                               }
                       }
                       ReadMode("restore");

# The variable $forwardTo is used to generate rewrite rules that
forward to the correct
# environment.I've omitted the rules here.

</perl>

The code works insofar that it waits 5 seconds and than proceeds with
the default I set, but it completely ignores any keypresses I make.
It is as if STDIN is not available at the time this code runs.
If I replace the ReadKey(5) with a ReadKey(5,STDIN) I get a syntax error.

Am I overlooking something, should I do this differently?
Is there any other possibility of interacting with the user during
apache startup, using mod_perl?

Krist



--
[EMAIL PROTECTED]
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

Reply via email to