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

I have a problem with the backtick not being ran under IIS 5.0 on windows XP. Has anyone encountered this before? Sample script: print "Content-type: text/html\015\012\015\012"; print "start"; print `dir `; print "end" You get this as a result: start end "Dir" is just an example, it will not run any shell commands.

Replies are listed 'Best First'.
Re: IIS 5.0 perl problem
by ikegami (Patriarch) on Aug 21, 2009 at 19:42 UTC
    What does the following output:
    print "Content-type: text/html\015\012\015\012"; print "<p>start</p>\n""; my $rv = `dir `; if (defined($rv)) { print $rv; } else { print "<p>[$!,$?]</p>\n"; } print "<p>end</p>\n";
      Prints: Bad file descriptor,-1 @Sandy: IIS is Internet Information Server, web server that is built into Windows XP. I should have mentioned, the sample script works fine off the command line. It also works fine when executed through any other web server. It's only when ran through IIS that it doesn't work properly. Mickysoft is doing something that disables CLI execution.

        hum, not very useful. I don't know what the problem could be, but it has nothing to do with Perl.

        Shelling out to use dir is pretty silly, so you could kill two birds with one stone by avoiding it. See readdir.

Re: IIS 5.0 perl problem
by Sandy (Curate) on Aug 21, 2009 at 20:42 UTC
    You forgot your quotes around `dir`.

    If you are executing on Unix, then it is trying to execute the executable "dir" and outputting the results.

    This does what you want

    $> perl -e 'print "`dir`\n"' `dir` $>
      He *wants* to execute dir.
        It's not executing any shell commands period. I agree, it's something Microsoft is doing that is stopping perl from working. If I ever find an answer, I'll come back and update the problem. Thanks to both of you for your help!
SOLVED !!
by rthawkcom (Novice) on Aug 23, 2009 at 16:05 UTC
    cd \Inetpub\AdminScripts
    adsutil set w3svc/CreateProcessAsUser 0
    adsutil set w3svc/CreateCGIWithNewConsole 1

    Works perfectly now!

    Why microsoft, why? Why do these things to people? You are truly evil!!

    Another useful setting to adjust thread limit: adsutil set w3svc/MaxConnections XX ...where XX is the max number of connections you want.

    List of commands (format must be altered to match examples above) that helped me solve this problem:

    http://nantcontrib.sourceforge.net/release/0.85-rc2/help/tasks/mkiisdir.html

    I hope this saves someone a lot of time, took me 2 days to crack this. Thanks to everyone who tried to help me solve it!