I am new to cgi and Perl, but i am trying to display ENV of of web page using a perl script. I created an index.html page inside of a vhost1 directory, which points to my .pl page which is inside my cgi-bin directory. the directory paths are as followed in coresponding order /var/www/html/vhost1/index.html and /var/www/html/vhost1/cgi-bin/first.pl. my index.html code is as followed
<html>
<head>
</head>
<body>
<h1>Hello World!</h1>
<a href = "cgi-bin/first.pl" target="_blank"> My First Perl Page</a>
</body>
</html>
And my .pl page is looks like
#!usr/bin/perl
print "Content-type: text/html \n\n ";
print "Hello, Nate";
foreach $key (sort keys %ENV)
{
print "$key -> $ENV($key) <br>\n";
}
I am using Centos7 to complete this project my URL path to my home page is http://131.183.223.173/vhost1/
I want my ENV results to display in a new tab rather then being downloaded to my computer.
#!usr/bin/perl
should be#!/usr/bin/perl
– ikegamiuse strict; use warnings qw( all );
. It will find a major and a minor error with your program. (It won't find your HTML injection error, though.) – ikegami#!usr/bin/perl
is a major problem here, I'm pretty sure it's not what is causing this behaviour. The web server isn't even trying to execute the program. I've never seen a web server configured so that if it can't successfully execute a CGI program, it will return the source code instead. That sounds like a major security issue! – Dave Cross