500 Internal Error, But script runs on shell!

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2008
Posts: 109
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 5
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

500 Internal Error, But script runs on shell!

 
0
  #1
Apr 4th, 2009
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:

  1. #!/usr/bin/perl
  2. use strict;
  3. use CGI;
  4. use CGI::Carp "fatalsToBrowser";
  5. use DBI;
  6. use LWP;
  7.  
  8. my $cgi = new CGI;
  9.  
  10. my $url = "http://www.google.com";
  11.  
  12. my $browser = LWP::UserAgent->new;
  13.  
  14. my $content = $browser->get($url);
  15. print $cgi->start_html(), $cgi->header();
  16.  
  17. my $doc= $content->content();
  18.  
  19. if(length($doc) > 100)
  20. {
  21. extractMeta($doc);
  22. }
  23.  
  24. print $cgi->end_html(), "\n";
  25.  
  26. sub extractMeta()
  27. {
  28. print "Inside subroutine";
  29. #Databse Information
  30. }

Can someone tell me whats killing it in the browser??
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,273
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 543
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: 500 Internal Error, But script runs on shell!

 
-7
  #2
Apr 4th, 2009
The 500 is most likely caused by an error in your server setup rather than the code itself
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 109
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 5
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: 500 Internal Error, But script runs on shell!

 
0
  #3
Apr 4th, 2009
Originally Posted by jbennet View Post
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!!
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,273
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 543
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: 500 Internal Error, But script runs on shell!

 
-7
  #4
Apr 4th, 2009
What platform and web server is it running?
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 109
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 5
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: 500 Internal Error, But script runs on shell!

 
0
  #5
Apr 4th, 2009
Originally Posted by jbennet View Post
What platform and web server is it running?
I think its apache
2.0.63
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 109
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 5
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: 500 Internal Error, But script runs on shell!

 
0
  #6
Apr 4th, 2009
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.
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 898
Reputation: KevinADC has a spectacular aura about KevinADC has a spectacular aura about 
Solved Threads: 67
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Posting Shark

Re: 500 Internal Error, But script runs on shell!

 
2
  #7
Apr 4th, 2009
You need to print the header first, not second:

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


should be:

print $cgi->header(), $cgi->start_html();
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 109
Reputation: sid78669 is an unknown quantity at this point 
Solved Threads: 5
sid78669's Avatar
sid78669 sid78669 is offline Offline
Junior Poster

Re: 500 Internal Error, But script runs on shell!

 
0
  #8
Apr 5th, 2009
Originally Posted by KevinADC View Post
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!!
Live free.... Die Hard!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Perl Forum


Views: 786 | Replies: 7
Thread Tools Search this Thread



Tag cloud for Perl
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC