943,837 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Marked Solved
  • Views: 1182
  • Perl RSS
Apr 4th, 2009
0

500 Internal Error, But script runs on shell!

Expand Post »
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:

PERL Syntax (Toggle Plain Text)
  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??
Reputation Points: 10
Solved Threads: 8
Junior Poster
sid78669 is offline Offline
195 posts
since Nov 2008
Apr 4th, 2009
-7

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

The 500 is most likely caused by an error in your server setup rather than the code itself
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,511 posts
since Apr 2005
Apr 4th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by jbennet ...
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!!
Reputation Points: 10
Solved Threads: 8
Junior Poster
sid78669 is offline Offline
195 posts
since Nov 2008
Apr 4th, 2009
-7

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

What platform and web server is it running?
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,511 posts
since Apr 2005
Apr 4th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by jbennet ...
What platform and web server is it running?
I think its apache
2.0.63
Reputation Points: 10
Solved Threads: 8
Junior Poster
sid78669 is offline Offline
195 posts
since Nov 2008
Apr 4th, 2009
0

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

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.
Reputation Points: 10
Solved Threads: 8
Junior Poster
sid78669 is offline Offline
195 posts
since Nov 2008
Apr 4th, 2009
2

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

You need to print the header first, not second:

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


should be:

print $cgi->header(), $cgi->start_html();
Reputation Points: 246
Solved Threads: 67
Practically a Posting Shark
KevinADC is offline Offline
898 posts
since Mar 2006
Apr 5th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by KevinADC ...
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!!
Reputation Points: 10
Solved Threads: 8
Junior Poster
sid78669 is offline Offline
195 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Using Special Variables
Next Thread in Perl Forum Timeline: Warning message: 'old-style' syntax





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC