954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

500 Internal Error, But script runs on shell!

Following is a perl script. It is running on shell when I go perl followed by the filename and works perfectly. But when I try to open it from browser, it gives back a 500. The permissions are fine because if i make some syntax error, it gives me the expected error message on browser screen:

#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp "fatalsToBrowser"; 
use DBI;
use LWP;

my $cgi = new CGI;

my $url = "http://www.google.com";

my $browser = LWP::UserAgent->new;

my $content = $browser->get($url);
print $cgi->start_html(), $cgi->header();

my $doc= $content->content();

if(length($doc) > 100)
{
	extractMeta($doc);
}

print $cgi->end_html(), "\n";

sub extractMeta()
{
	print "Inside subroutine";
	#Databse Information
}


Can someone tell me whats killing it in the browser??

sid78669
Junior Poster
197 posts since Nov 2008
Reputation Points: 10
Solved Threads: 8
 

The 500 is most likely caused by an error in your server setup rather than the code itself

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,820
Solved Threads: 600
 
The 500 is most likely caused by an error in your server setup rather than the code itself


Well, in that case, Its my college server. Someone must have crashed it! Thanks!!

sid78669
Junior Poster
197 posts since Nov 2008
Reputation Points: 10
Solved Threads: 8
 

What platform and web server is it running?

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,820
Solved Threads: 600
 
What platform and web server is it running?

I think its apache
2.0.63

sid78669
Junior Poster
197 posts since Nov 2008
Reputation Points: 10
Solved Threads: 8
 

the weird thing is its showing me syntax errors in the browser when i deleberately remove a semmi-colon or alike. But is not showing anything when everything is right. So i think it rules out the possibility of wrong permissions.

sid78669
Junior Poster
197 posts since Nov 2008
Reputation Points: 10
Solved Threads: 8
 

You need to print the header first, not second:

print $cgi->start_html(), $cgi->header();


should be:

print $cgi->header(), $cgi->start_html();

KevinADC
Posting Shark
921 posts since Mar 2006
Reputation Points: 246
Solved Threads: 67
 

You need to print the header first, not second:

print $cgi->start_html(), $cgi->header();

should be:

print $cgi->header(), $cgi->start_html();

Thanks, you were right!!

sid78669
Junior Poster
197 posts since Nov 2008
Reputation Points: 10
Solved Threads: 8
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You