OOPS, A slight typo there.

Anyway, perhaps a little more information might accelerate obtaining a
useful response.

What I have found is quite baffling.  A practice I routinely use on Apache's
httpd server, which works fine, does not work when I try the same thing with
Tomcat's CGI.

Here is a code snippet:

my $output = `C:\\ApacheAndPerl\\Apache2\\perl\\printenv_segment.pl`;
print "$output<br><br><br><br>";
$output = `dir`;
print '<PRE>';
print "$output<br>";
print '</PRE>';
print '</BODY></HTML>';

And here is printenv_segment.pl:
#!C:/Perl/bin/perl
print '<H3>Environment variables</H3><UL>';
foreach my $var (sort keys %ENV) {
  my $val = $ENV{$var};
  $val =~ s|\n|\\n|g;
  $val =~ s|"|\\"|g;
  print qq{<LI>${var} = "${val}"</LI>\n};
}

print '</UL>';

Obviously ALL I did is extract enough code from the printenv perl script
that was distributed with the windows version of httpd that had been bundled
with a distribution of perl.  Any code that prints something to standard out
would do (though to be legible, you'd have to wrap it in <PRE></PRE> as I
did for Windows' dir command.

The point is that this works PERFECTLY using CGI on Apache's httpd server
and yet nothing written to standard out by the child script is captured and
added to the page when the same code is executed within Tomcat 6's CGI. 
WHY?  Is CGI on Tomcat 6 not able to handle child CGI scripts?  If not, I
can work with CGI on Apache's httpd server, but then I have to figure out
how to maintain session state when moving from a JSP page on Tomcat to a
page (created by a CGI perl script) on Apache's httpd server, and back.  My
application has a login, and that login info has to be maintained through
this route.

Thanks

Ted



Ted Byers wrote:
> 
> My Martin,
> 
> What was labelled as array2d is in fact array2d.pl  There is nothing more
> in it than what you see in my first post.
> 
> If you want me to email it to you, send me an email address.  I have not
> found, in the interface to nabble, a way to attach a file to a message,
> email or otherwise.
> 
> I can email both scripts if you wish.  Just tell me where, but the
> contents of both are provided in the first message in this thread.
> 
> Thanks
> 
> Ted
> 
> mgainty wrote:
>> 
>> 
>> please supply array2d.pl
>> 
>> thanks,
>> Martin 
>> ______________________________________________ 
>> Disclaimer and confidentiality note 
>> Everything in this e-mail and any attachments relates to the official
>> business of Sender. This transmission is of a confidential nature and
>> Sender does not endorse distribution to any party other than intended
>> recipient. Sender does not necessarily endorse content contained within
>> this transmission. 
>> 
>> 
>>> Date: Tue, 26 Aug 2008 15:44:35 -0700
>>> From: [EMAIL PROTECTED]
>>> To: users@tomcat.apache.org
>>> Subject: Another question about CGI on Tomcat 6 - access
>>> 
>>> 
>>> I have CGI working.  Now I have a question about having one cgi script
>>> execute another script (both simple enough to be appended below).
>>> 
>>> I can run either within Emacs, or from a commandline, and get the
>>> obvious
>>> output.  Running format_test I get the following output:
>>> 
>>> Content-type: text/html
>>> 
>>> <HTML><HEAD>
>>> <TITLE>Arrays</TITLE>
>>> </HEAD>
>>> 
>>> <BODY>
>>> a   0.0550001       0.06    $0.06<br>
>>> b   150.3449        150.34  $150.34<br>
>>> c   1158.435        1158.43 $1,158.43<br>
>>> mc  -1158.435       -1158.43        $-1,158.43<br>
>>> d   100256147.258   100256147.26    $100,256,147.26<br><br><br>
>>> 
>>> 
>>> <PRE>\n12
>>> 13
>>> 2
>>> 3
>>> 
>>> </PRE>\n</BODY>
>>> 
>>> No surprises.  However, when the same script is executed as a cgi
>>> script,
>>> the output from array2d.pl is missing:
>>> <HTML><HEAD>
>>> <TITLE>Arrays</TITLE>
>>> </HEAD>
>>> 
>>> <BODY>
>>> a   0.0550001       0.06    $0.06<br>
>>> b   150.3449        150.34  $150.34<br>
>>> c   1158.435        1158.43 $1,158.43<br>
>>> mc  -1158.435       -1158.43        $-1,158.43<br>
>>> d   100256147.258   100256147.26    $100,256,147.26<br><br><br>
>>> 
>>> 
>>> <PRE>\n
>>> </PRE>\n</BODY>
>>> 
>>> I do not get any error messages at all.
>>> 
>>> Why am I not getting any output at all from the child processes?  I NEED
>>> to
>>> be able to invoke another perl script, ideally from another directory
>>> outside the Tomcat directory tree, have it complete successfully and
>>> return
>>> a message to that effect.  In due course, I will use the perl cgi
>>> package
>>> and redirect the browser to a JSF page in my web app, hopefully
>>> maintaining
>>> the session prviously established by my app.
>>> 
>>> Help getting this working would be greatly appreciated.
>>> 
>>> Thanks
>>> 
>>> Ted
>>> ====Appendix==========================
>>> Here are two trivially simple scripts:
>>> 
>>> #array2d
>>> # I used this to help a colleague learn the basics of using arrays in
>>> Perl.
>>> use strict;
>>> 
>>> my @matrix;
>>> my @vector = [1,2,3];
>>> push (@matrix,@vector);
>>> @vector = [11,12,13];
>>> push (@matrix,@vector);
>>> print "$matrix[1][1]\n";
>>> print "$matrix[1][2]\n";
>>> print "$matrix[0][1]\n";
>>> print "$matrix[0][2]\n";
>>> 
>>> And here is the main CGI script (derived from a script I used to help a
>>> colleague learn about formatting numbers in Perl)
>>> #format_test.pl
>>> #!c:/perl/bin/perl.exe
>>> use strict;
>>> print <<"END";
>>> Content-type: text/html
>>> 
>>> <HTML><HEAD>
>>> <TITLE>Arrays</TITLE>
>>> </HEAD>
>>> 
>>> <BODY>
>>> END
>>> 
>>> my $a = 0.0550001;
>>> my $b = 150.3449;
>>> my $c = 1158.435;
>>> my $mc = -1158.435;
>>> my $d = 100256147.258;
>>> 
>>> my $rv1a = sprintf("%.2f",$a);
>>> my $rv1b = sprintf("%.2f",$b);
>>> my $rv1c = sprintf("%.2f",$c);
>>> my $rv1mc = sprintf("%.2f",$mc);
>>> my $rv1d = sprintf("%.2f",$d);
>>> 
>>> my $rv2a = commify($rv1a);
>>> my $rv2b = commify($rv1b);
>>> my $rv2c = commify($rv1c);
>>> my $rv2mc = commify($rv1mc);
>>> my $rv2d = commify($rv1d);
>>> 
>>> print "a\t$a\t$rv1a\t\$$rv2a<br>\n";
>>> print "b\t$b\t$rv1b\t\$$rv2b<br>\n";
>>> print "c\t$c\t$rv1c\t\$$rv2c<br>\n";
>>> print "mc\t$mc\t$rv1mc\t\$$rv2mc<br>\n";
>>> print "d\t$d\t$rv1d\t\$$rv2d<br><br><br>\n\n\n";
>>> 
>>> my $output = `array2d.pl`;
>>> print '<PRE>\n';
>>> print "$output\n";
>>> print '</PRE>\n';
>>> print '</BODY>';
>>> sub commify {
>>>   my $value = reverse $_[0];
>>>   $value =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
>>>   return scalar reverse $value;
>>> }
>>> 
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Another-question-about-CGI-on-Tomcat-6---access-tp19171791p19171791.html
>>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>> 
>> 
>> _________________________________________________________________
>> See what people are saying about Windows Live.  Check out featured posts.
>> http://www.windowslive.com/connect?ocid=TXT_TAGLM_WL_connect2_082008
>> 
>  http://www.nabble.com/file/p19173428/array2d.pl array2d.pl 
> 

-- 
View this message in context: 
http://www.nabble.com/Another-question-about-CGI-on-Tomcat-6---access-tp19171791p19189969.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to