i have got xampp1.6.8


when i run this program in localhost

#!"C:\xampp\perl\bin\perl.exe"
print "Content-type: text/html\n\n";
print '<html>';
print '<head>';
print '<meta name="author" content="Kay Vogelgesang">';
print '<link href="/xampp/xampp.css" rel="stylesheet" type="text/css">';
print '</head>';
print "<body>&nbsp;<p><h1>Sairam with MiniPerl</h1>";
print "CGI with MiniPerl is ready ...</body></html>";

it runs

but when it contains perl scripts it does not run as given below

#!"c:\xampp\perl\bin\perl.exe"
print "Content-type: text/plain","\n\n";
print "Welcome to Shishir's WWW Server!", "\n";
$remote_host = $ENV{'REMOTE_HOST'};
print "You are visiting from ", $remote_host, ". ";
$uptime = `/usr/ucb/uptime` ;
($load_average) = ($uptime =~ /average: ([^,]*)/);
print "The load average on this machine is: ", $load_average, ".", "\n";
print "Happy navigating!", "\n";
exit (0);

Recommended Answers

All 6 Replies

as far as I know there should be no quotes on the shebang line:

#!c:\xampp\perl\bin\perl.exe

but you're better off using forward slashes, which Windows fully supports:

#!c:/xampp/perl/bin/perl.exe

backslashes in perl code create escape sequences, not on the shebang line which is a special line in a perl program, but its a good habit to use forward slashes in file/directory paths whenever possible to avoid the problem intirely. Note that DOS does not support forward slashes so if you ever do something in DOS you will have to use backslahes in directory paths.

This doesn't have any effect on xampp. I made:

C:/xampp/perl/bin/perl.exe
print "Content-Type: text/html";
print "OK";

I hate to bump an old thread, but I REALLY need help.

This doesn't have any effect on xampp. I made:

C:/xampp/perl/bin/perl.exe
print "Content-Type: text/html";
print "OK";

I hate to bump an old thread, but I REALLY need help.

Don't forget the double newlines after text/html - otherwise you're not sending a valid header.

#!C:/xampp/perl/bin/perl.exe
print "Content-Type: text/html\n\n";
print "Hello, World!";

After looking at your first code it seems you're trying to execute a binary in a UNIX/Linux style directory structure...

$uptime = `/usr/ucb/uptime`;

It was most probably failing because of that.. Try something simple, like getting the environment variables.

#!C:/xampp/perl/bin/perl.exe

print "Content-type: text/html\n\n";

for (keys %ENV) {
    print "$_ => $ENV{$_}<br />\n";
}

Thanks insertable. Also, in xampp, I've set up a ScriptAlias /cgi-bin/ "C:/xampp/cgi-bin/" but on my Website (test.pl), it's a 500 Error.
-edit:
Server error!

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.
Error 500

Should I edit in another shebang? Sorry, but I'm a n00b at this Perl thingymajig

You could try changing the direction of the slashes in the shebang, ie:

#!C:\xampp\perl\bin\perl.exe

If that's still not working, check the path of the Perl interpreter and make sure it's correct.

Could you please copy the last few lines of output from Apache's error log and paste it here also? That should give us some kind of helpful information, hopefully.

A majority of the time 500 errors (Internal Server Error) is caused by:

* Bad shebang
* Error in the script
* Bad .htaccess file in the directory
* Incorrect file permissions (Usually on *NIX platforms, not Windows)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.