1

I need small virtual machine with a Web server, so I decided to install Damn Small Linux. I need to run a Web server that is hosting a site with a script that checks for a server's IP address and returns it in a HTML page. So far I have something like this working:

Script file:

#!/usr/bin/perl

print "Content-type: text/html\n\n" ;
print <<EOF ;
<html>
<head><title>CGI Results</title></head>
<body>
<h1>Hello, world.</h1>
</body>
</html>
EOF
exit ;

The script is called from HTML like this:

<iframe src="http://localhost/cgi-bin/skrypt.cgi" width="100%"></iframe>

It's working fine, but whenever I add something to this script other than a print statement, for example:

my $address = "someValue"

… then the HTML page is not running the script but instead it is downloading it. What do I have to do to make this script work? I just need an IP address to appear on the Web page.

2
  • Downloading it may be a matter of web server configuration instead. What webserver are you using? Does it need to be configured to not allow downloading of cgi-bin/ content? Commented May 11, 2012 at 23:55
  • From the Stack Overflow Perl FAQ: How can I troubleshoot my Perl CGI script? Commented May 12, 2012 at 14:56

1 Answer 1

2

Try to run your cgi script in the command line:

perl -c my_script.cgi

and if it is ok, try to run using strict and warnings activated.

#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;

If there is no problem, look into the error log.

Sign up to request clarification or add additional context in comments.

1 Comment

I used perl -c my_script.cgi command and it found some bugs. Thank you very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.