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

Hi most revered monks,

I am trying my very first perl-cgi script using testing it with Lincoln Stein's script like this.And I store this script as "myfirst_cgi.pl" under /var/www/cgi-bin directory

My problem is why upon opening -- http://localhost/cgi-bin/myfirst_cgi.pl -- it gives this instead of this?

This is my httpd.conf and httpd2.perl.conf by the way.

Can anybody suggest what's wrong with my approach? Hopefully this question is not far off topic.
Thanks a lot beforehand.

Retitled by davido from 'My very first perl CGI question'.

Replies are listed 'Best First'.
Re: Incorrect output from CGI script
by g0n (Priest) on Jan 26, 2005 at 16:30 UTC
    Your header line in the output you refer to says: calling : http://localhost/cgi-bin/test.pl through web browser

    have you called the wrong script? It certainly looks like it - the ENV script is another of the sample CGI scripts.

      Oops, sorry it should be http://localhost/cgi-bin/myfirst_cgi.pl , I change the code name 'on the fly', really sorry. So no, I am calling the right script.

      What do you mean by ENV script btw? How/where can I get it?

        Try naming the script "myfirst_cgi.cgi" instead of ".pl". Sometimes webservers are configured to expect that. Make sure permissions are set properly for the script to be executed by your webserver also. Sometimes webservers are of group "nobody", for example. And make sure the shebang line is correct.


        Dave

        Greetings all,
        The ENV script is a script written to print out all of the name=value pairs of the the %ENV hash. The %ENV hash contains elements relating to your environment, which in most cases differs depending on where a particular script is run (i.e. executed from a web server vs. from the command line.). The output you posted looks like an ENV script as described above and the reason test.pl was mentioned is that the environment variables SCRIPT_NAME and REQUEST_URI are both set to /cgi-bin/test.pl. If this was your script it would be set to /cgi-bin/myfirst_cgi.pl.

        -InjunJoel
        "I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo