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

Setup: - Windows XP box with IIS (Internet Information Server) running
Jeff Zucker wrote this great cgi script that given a "mod" query string parameter equal to the module you want the perldocs for, it will display the perldocs for that module in the browser. I renamed Jeff's script "perldoc_test.pl" on my Windows XP box, and added some code in an effort to be able to get "perldoc perl" output in the browser - I've highlighted the code I added :
------------------------------------------------------------------ #!perl # by Jeff Zucker # # may be freely modified and distributred under the same terms as Perl + itself # use strict; use CGI; use CGI::Carp qw/fatalsToBrowser/; use File::Find; use Pod::Html; my $q = new CGI; my $modname = $q->param('mod') || ''; show_form(); if( $modname =~ /^perl/ ) { show_perl($modname); } ### I (HM) added th +is ### elsif( $modname =~ m#/# ) { show_dir($modname); } else { show_pod( $modname ); } ### I (HM) added this subroutine ### sub show_perl { my $text = `C:\\Perl\\bin\\perldoc.bat perl`; print <<END_HTML; <body> <h2>Testing222</h2> <pre>\$text=[$text]</pre> </body> </html> END_HTML } # end show_perl sub show_form { print $q->header, $q->start_html(-title=>'POD FINDER'), $q->start_form, $q->b("Module Name : "), $q->textfield(-name=>'mod'), $q->end_form, $q->end_html, ; } sub show_pod { my $modname = shift; return unless $modname; $modname =~ s#::#/#g; my $filename = findmod( $modname ); pod2html("--quiet","--infile=$filename") if $filename; } sub show_dir { my $dir = shift; $dir =~ s#/$##g; my $scriptname = $q->script_name; for(@INC){ my $fdir = "$_/$dir"; if( -d $fdir ) { opendir(D,$fdir) || die $!; my @files = readdir D; closedir D; for(@files) { next unless /(.*)\.pm$/; print "<a href='$scriptname?mod=$dir\:\:$1'>$dir\:\:$1 +</a><br>"; } } } return ''; } sub findmod { my $mod = shift; if (-e $mod ) { return $mod; } for(@INC){ my $modname = "$_/$mod.pm"; if( -e $modname ) { return $modname; } } return ''; } __END__ ------------------------------------------------------------------
When I run that with this URL:
http://localhost/Test_Perl/perldoc_test.pl?mod=perl
trying to basically get "perldoc perl" output to the browser, I get this output displayed in the browser:
Module Name : perl Testing222 $text=[]
As you can see there is no output captured from the
my $text = `C:\\Perl\\bin\\perldoc.bat perl`;
command. And no error appears. I have more experience with Apache on Red Hat Linux - there if the webserver had a permissions problem executing a command, it would appear in the apache error.log file, but I can't locate any such animal on Windows. Is there an error log for IIS?

When I run that command in a perl command line script it runs fine. Must be something with my IIS setup, but I don't know what. I've tried adding the webserver anonymous user to the security profile for C:\Perl\bin\perldoc.bat, but that didn't have any effect. Can anyone else get this working on their Windows XP box with IIS(Internet Information Server) webserver? Any help or insight is appreciated.

Replies are listed 'Best First'.
Re: perldoc.cgi - problem on WinXP
by meetraz (Hermit) on Jun 28, 2004 at 21:12 UTC
    Yes, there are log files for IIS, but I'm not sure if the default configuration would hold the information you are looking for. You may need to enable more verbose logs.

    In addition to giving the IUSR account permissions to the batch file, it will also need read & execute permissions to the perl installation, any system DLL files that perl links to, and read/write permissions to any temp directories that your script (or perldoc.bat) may be using.

    What happens if you change this line:

    my $text = `C:\\Perl\\bin\\perldoc.bat perl`;

    to

    my $text = `ipconfig`;

    Does it give the proper output?

      Good thought! I tried `ipconfig` but I get the same
      $text=[]
      I'm a WinXP newbie and still not very familiar with permissions issues on this platform - I tried adding the IUSR_my machine user to the C:\Perl directory, but that had no effect on the output. Any suggestions for what to try next?
Re: perldoc.cgi - problem on WinXP
by jZed (Prior) on Jun 29, 2004 at 16:40 UTC
    There are two problems I can see - 1) my original script only looks for .pm, not .pod, and 2) you are trying to run perldoc with backticks. My script doesn't call the .bat file "pod2html", it requires the module Pod::Html and uses its internal "pod2html" command - notice there are no backticks or system command around "pod2html" in my script. This allows the module to find the directories rather than invovling the shell as yours does with backticks.

    I've updated the original script to check for .pod as well as .pm. This means that you can get a list of all of the non-moudule pods with mod=Pod/ (gives you a clickable list of the whole lib/Pod directory). You can also get individual pods in that directory with mod=Pod::perl or mod=Pod::perlreftut, etc.

    -- Jeff