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

Hello, I've just started Perl programming, am learning with a NT Server, and am doing all my programms on windows. I am trying to upload a simple hello program to my server and have uploaded it successfully. The problem is that when I try and open the file from a browser I do not get hello world written on the screen but a box asking where I want hello.perl.exe saved. Perl.exe is the extension to be used for my server and there is no directory needed. I can save and open this file but it just show's the programm I have written to put Hello world on the screen. Here is a copy of my programm I was wondering if I'm doing something wrong or if anyone else has had this kind of problem and can help?
#!/usr/bin/perl.exe -w use CGI qw(:standard); use strict; print header; print "<B>Hello, World!</B>";
Is there something I must do to run the program through the server? It seems as if it's only letting me access the program instead of it running the programm for me, (I have tested it in ms dos and the program does work on my system). I'm typing in www.myserver(my web domain name).com/Hello.perl.exe and that is when I get the dialog box asking where I want to save the file. I have uploaded the file by cuteftp, with the perl.exe extension on the end. Thank you for your help, Monkette!

Edit: chipmunk 2001-03-07

Replies are listed 'Best First'.
Re: Win. Ftp. Files, Browsers
by dfog (Scribe) on Mar 08, 2001 at 00:53 UTC
    IIS (if that is what you are running as your webserver) needs to have an extention added to it. The shebang line is meaningless in respect to associating the file with perl in windows NT. Perl itself seems to read the line after execution has begun and will use any switches it finds there. By default, I believe activestate perl will add .pl files to be interpreted by perl. This means that if you have a file named hello.pl saved in an executable directory, perl will automatically run and the output will be sent to the browser.

    The other issue is most browsers require the line
    print "Content-Type: text/html\n\n";
    If you do not have this line in your code before your first print statement, browsers like netscape will try to download the output, rather than display it to the screen.

    Hope this helps.

    Dave

    UPDATE
    That second part is unnecessary, as the print header should take care of it.

Re: Win. Ftp. Files, Browsers
by athomason (Curate) on Mar 08, 2001 at 00:37 UTC
    Are you sure you're reading the CGI instructions for your server correctly? I've never heard of a perl.exe extension being required to mark a script as a CGI executable. The shebang line in your script should be enough to tell the server where perl is, though I somehow doubt perl is in /usr/bin on an NT system. Did you mean something like #!C:\perl\bin\perl.exe -w?

    The script-downloading behavior you mention is symptomatic of the web server not treating your script as executable. So, what's the right way to do it? That depends mostly on the webserver you're running and how it's configured. There are a few common configurations, but these are the two I've encountered most often:

    • Files inside a specific directory, e.g. /~user/cgi/, /cgi-bin/, etc., are always interpreted as scripts. Just upload to that directory and, assuming your script works, you'll see its output in your browser.
    • Specific extensions, most commonly .cgi, sometimes .pl, are interpreted as scripts. .perl.exe sounds a bit bizarre; tou shouldn't need the name or location of the interpreter in the script filename. The webserver or OS should be aware of where to find perl once it recognizes your script as such.
    In either case, your administrator should know where to put and how to name scripts so that they'll actually execute. If you're the administrator, read up on your webserver docs.
      Thanks I figured out where the directory is I was looking in the wrong place and it works!! This web site is the best, now that I've done my first program I'm must figure out how to make a form and have people be able to send the iformation back to me!! I love programming it gets to you when it does not work out but when it does it's great!!! Thanks again for your help, Monkette :)