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

I am very new to CGI and perl, so please pardon my ignorance. The server that hosts my website is a Windows 2000 server and they have ActiveState Perl, all I need to know is what to set the first line of code to in a cgi program, where you give the path to perl on your server. I have asked my server administrator, but they cannot answer programming questions. They said that as long as the program is uploaded as .pl instead of .cgi it should run. Can anyone help me?

Edit kudra, 2002-05-28 Changed title

  • Comment on ActiveState Perl and CGI: specifying perl path (was ASPN and CGI)

Replies are listed 'Best First'.
Re: ASPN and CGI
by Kanji (Parson) on May 28, 2002 at 16:53 UTC

    #!perl is the most common shebang line I've seen in Windows environments and should work fine.

    If you want/need something more explicit, try #!c:\perl\bin\perl (which is the default for an ActivePerl install) or perhaps the same path but different drive letter if the server has more than one available.

        --k.


Re: ASPN and CGI
by emcs (Scribe) on May 28, 2002 at 17:00 UTC
    My web site used to be hosted on a Win 2000 server; I always started my scripts out with:

    #!perl -w

    But my scripts would run without perfectly well without it.

    They worked in any location and did not have to be in the CGI directory.

    The dogs bark; but the caravan rolls on.

Re: ASPN and CGI
by Aristotle (Chancellor) on May 28, 2002 at 17:40 UTC
    On Windows machines scripts are commonly associated with their interpreter by way of their extension. The shebang line is a Unix mechanism; you should even be able to do fine leaving it out completely; if not, #!perl should do. If you don't need the shebang line, I'd make it #!/usr/bin/perl so that your scripts run anywhere without modifications.

    Makeshifts last the longest.

Re: ActiveState Perl and CGI: specifying perl path (was ASPN and CGI)
by flounder99 (Friar) on May 28, 2002 at 19:44 UTC
    You need to have .cgi associated with perl just as .pl is. That way the web server will hand .cgi files to the perl interperter. You won't need a shebang at the beginning of the .cgi file.

    using windows explorer:

    tools->folder options
    select the file types tab
    click on New
    type in .cgi
    click on OK
    click on Change
    select Perl Command Line Interpreter
    click Close

    flounder

Re: ActiveState Perl and CGI: specifying perl path (was ASPN and CGI)
by thunders (Priest) on May 28, 2002 at 21:59 UTC

    In my experiance, at least for Apache server and IIS for windows a #!perl is necessary. this same line is not necessary for console programs, which sometime confuses new users because the console spits out valid HTML, but they get 500 errors from a browser.

    Generally if perl is on the path(usually the case with active state install) #!perl will do it, otherwise you need the full #!C:\Perl\bin\perl you can add .exe to that but it's not necessary.

    You can configure apache to recognize .cgi as a file to be interpreted by perl, but this is not general practice because cgi programs can be written in many languages.

    One (possibly obvious) thing to note cgi scripts usually can only be run from specific directories, commonly cgi-bin, but I've seen it be called "scripts" as well.