ppmss has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
i've got problems with a little cgi-script in a w2k3 - tomcat 4.1.3.1 environment (see below).
Starting the script in a dos shell $p->proto == 6. Starting it via cgi-servlet I get Null for $p.
Starting ping in dos - name is resolved.
Starting ping from cgi-script - name cannot be resolved.
passShellEnvironment is set true.
Has anybody any idea what I can do in tomcat-catalina?
With IIS it works ok, but I have to use this tomcaz-only-version.
Thanks, peter
-------------------------------------
use Net::protoent;
$p = getprotobyname('tcp');
if( $p == 0 ){
$p = "no proto";
}
print "Content-type:text/html\n\n";
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n";
print "<html><head><title>protobyname</title></head>\n";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"/CAisd/css/analyst_styles.css\">\n";
print "<body>\n";
print "Test getprotobyname
\n";
if ($p != 0 ){
printf "proto for %s is %d, aliases are %s
\n", $p->name, $p->proto, "@{$p->aliases}";
} else {
print "No Proto
\n";
}
print "</body></html>";

Replies are listed 'Best First'.
Re: problem with cgi-pms under tomcat-env
by Illuminatus (Curate) on Oct 15, 2008 at 20:27 UTC
    The user and environment that apache runs under will depend on how it is configured. You could use Data::Dumper to print out %ENV and @INC. You should also be using:
    use strict; use warnings;
      Thanks,

      setting $ENV{SYSTEMROOT}="C:\\WINDOWS";
      at the start of the CGI-script solves the problem.

      Peter