http://qs1969.pair.com?node_id=842030

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

So, anyway . . . I've got two near-identical Windows 2003 servers - live and test.

I have the same version of IIS (6.0) installed on both servers, but different versions of Perl.

On the live server, I have ActiveState 5.8.8. On the test server, I have Strawberry 5.12

I have the same script on both servers. The script begins like this:

use FindBin qw($Bin $Script); use lib "$FindBin::Bin/../lib"; use strict; use warnings; use Text::CSV; use CGI; use CGI::Session; use Net::LDAP; use DBI; use LWP::Simple;

I then define $session:

my $cgi = new CGI; my $session = new CGI::Session(undef, $cgi, {Directory=>'c:\temp'});

and I define the subroutine, output_header, to output the beginnings of a web-page:

sub output_header { my $current_session = $_[0]; my $wrb_url = $_[1]; # so what about the NPH thing?! print $current_session->header(-nph=>1); # print $current_session->header(); print <<ENDOFTEXT; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> ... [loads of HTML stuff goes here . . . ] ... ... </head> ENDOFTEXT }

I then call my subroutine:

output_header($session, $wrb_url);

Note: you can disregard $wrb_url - it's not important. The rest of the script works fine and just outputs the rest of a web-page, including the final </body> and </html> tags. In fact, the problems SEEM to start before the <head> tag, possibly something to do with the HTTP stuff sent right at the beginning. On the test server, the browser returns CGI Error, with the line under that reading: 'The specified CGI application misbehaved by not returning a complete set of HTTP headers.'. The live server works fine. The only difference I've been able to spot in the HTTP is the inclusion of the following line on the live server:

Cookie: CGISESSID=52308b820ff99fd3d4dca46c4b7a5280

[obviously the value of CGISESSID changes] This line is absent in the HTTP from the test server. I've been tearing my hair out trying to work out what on earth is wrong and why I'm getting that CGI error. Anyone?

Replies are listed 'Best First'.
Re: Strawberry Perl and IIS not playing
by mr_mischief (Monsignor) on May 28, 2010 at 12:46 UTC
    Not sending a complete set of HTTP headers often means not sending any. Not sending any often means the program is dying before it produces any output. Try running your code under Strawberry as the IIS user and see if it gives you any errors. That, or try CGI::Carp or something to get the errors in your browser.
    use CGI::Carp qw( fatalsToBrowser ); die "Fatal error messages are now sent to browser";

      Many thanks for this. We may be getting there. I'm not too sure how to make the change with regard the IIS user. However, I've done the CGI::Carp thing and a page came back thus:

      Software error:

      install_driver(mysql) failed: Can't load 'C:/strawberry/perl/vendor/li +b/auto/DBD/mysql/mysql.dll' for module DBD::mysql: load_file:The spec +ified module could not be found at C:/strawberry/perl/lib/DynaLoader. +pm line 200. at (eval 42) line 3 Compilation failed in require at (eval 42) line 3. Perhaps a required shared library or dll isn't installed where expecte +d at c:\inetpub\wwwroot\index_test.pl line 223

      For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

      ----------- END OF ERROR ---------------

      I checked out line 200 of DynaLoader.pm and it contains this:

      my $libref = dl_load_file($file, $module->dl_load_flags) or croak("Can +'t load '$file' for module $module: ".dl_error());

      But then immediately before this is the following comment:

      # Many dynamic extension loading problems will appear to come from # this section of code: XYZ failed at line 123 of DynaLoader.pm. # Often these errors are actually occurring in the initialisation # C code of the extension XS file. Perl reports the error as being # in this perl code simply because this was the last perl code # it executed.

      Down the rabbit hole we go . . .

        This most likely means that either DBD::mysql is not installed on your machine or that at least one of the DLLs required by DBD::mysql is not installed. You will likely need to install (and potentially set up) the MySQL client.

        Do you have DBD::mysql installed on this server? Check out the instructions INSTALL file.

        Update: fixed typo in module name, added link to INSTALL file.

Re: Strawberry Perl and IIS not playing
by bunchily (Novice) on May 28, 2010 at 14:16 UTC

      Personally, I prefer to put dependent DLLs into the same directory as the perl.exe executable, that is, usually c:\Strawberry\Perl\bin. This prevents surprises when I uninstall/reinstall a module.

        That's a good way, but libmysql_.dll came with strawberryperl
        strawberry\c\bin\libcharset-1_.dll strawberry\c\bin\libeay32_.dll strawberry\c\bin\libexpat-1_.dll strawberry\c\bin\libexslt-0_.dll strawberry\c\bin\libfreetype-6_.dll strawberry\c\bin\libgcc_s_sjlj-1.dll strawberry\c\bin\libgd-2_.dll strawberry\c\bin\libgif-4_.dll strawberry\c\bin\libglut-0_.dll strawberry\c\bin\libiconv-2_.dll strawberry\c\bin\libjpeg-62_.dll strawberry\c\bin\liblzma-0_.dll strawberry\c\bin\libmysql_.dll strawberry\c\bin\libpng-3_.dll strawberry\c\bin\libpng12-0_.dll strawberry\c\bin\libpq_.dll strawberry\c\bin\libssl32_.dll strawberry\c\bin\libssp-0.dll strawberry\c\bin\libtiff-3_.dll strawberry\c\bin\libxml2-2_.dll strawberry\c\bin\libXpm_.dll strawberry\c\bin\libxslt-1_.dll strawberry\c\bin\libz_.dll
        which adds/expects strawberry\c\bin\ and strawberry\perl\bin\ in %PATH%
      Congratulations, but that is the stupid way to do it :) Just add C:\strawberry\c\bin\ to your %PATH%
      I used "site" path instead of "vendor" in Windows 2012 R2 That is, to quote: "copy C:\strawberry\c\bin\libmysql_.dll to C:\strawberry\perl\site\lib\auto\DBD\mysql\libmysql_.dll." now it's works.
        I have have terrible time trying to get this to work on Windows Server 2012 R2. Could you please list in detail how to get this to work? Thanks
      I cannot thank you enough for this work around. Thanks a ton!