![]() |
Any Perl expert ?
I am running a script and I get an internal server error.
No diagnostic. I know only very little of Perl language. I can't find out what the problem is here. Anyone can tell me what is wrong with this script? ########################################### #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use diagnostics; use CGI; use HTTP::Request::Common qw(POST); use LWP::UserAgent; $q = CGI->new(); $ua = LWP::UserAgent->new(); $req = POST 'http://maxmind.com:8010/b', [ l => "hgfjgfdhhh", i => "69.70.92.38", ]; $k = new CGI($res->content()); $region = $k->param( region ); $city = $k->param( city ); $country = $k->param( country ); print "Content-type: text/html\n\n"; print "$region\n"; exit; ###################################### Thanks ! |
i => "69.70.92.38",
Should not be a comma after the last one. That's the only thing I see right now. If that doesn't work, check the message in Apache's error log. |
Quote:
I corrected this misstake but it still doesn't work. I just asked webair to let me see my Apache's error log. |
Quote:
CGI::Carp qw/fatalsToBrowser/ would catch this. OP is correct to check apache logs. |
BTW, dude, don't print "Content-type....."
just do print $k->header(); |
try this
Code:
#!/usr/bin/perl |
I doubt the "new cgi()" is any good though.
|
Quote:
Thanks for your help. I just tried the exact code here and it still doesn't work. I still get an internal server error message. I don't understand why " use CGI::Carp qw(fatalsToBrowser); " doesn't show anything to help... |
If I run my version here I don't get an error.
Do you have the loaded perl modules installed? These are not standard modules on webair I believe. Hit up webair tech live and tell 'em to install these three: (LWP::UserAgent, HTTP::Request::Common and CGI). |
you should find the error messages in the server's error log file. check out, or find out, where the server or virtualhost's ErrorLog directive is pointed to (i'm assuming you're using Apache).
adding 'use strict' near the top and using 'perl -wc file.cgi' from the command line may also give you some hints. |
The first thing I check is to see if the Perl path is correct and if the script was uploaded as ASCII or binary. That's where I usually screw up.
|
chmod 0755?
|
Thanks all for your help.
Yes, Perl path is correct, my files are uploaded as ASCII and were CHMOD 755 - FuqALot : I asked a webair tech to make sure HTTP::Request::Common is installed. I am waiting for his answer. The 2 other Perl models are installed for sure. - salsbury : I am waiting on Webair to have access to my Apache error log file. |
perl -e 'use HTTP::Request;'
do the rest of them as well. if it returns 0, you're module is installed. If it bitches, its not. |
I finally got access to my error log file.
Here is the error massage I get when I try to run the script: [Mon Feb 20 14:48:23 2006] [error] [client 556.200.545.202] File does not exist: /www/virtual/jonjovi/www.domain.com/public_html/favicon.ico I don't know what it means at all ! |
That only means that when a browser tries to visit your site, there isn't an icon available (an icon that you would see next to the address in the browser window) - I doubt that's the reason why your perl program isn't doing anything.
What *are* you trying to do? What do you want the perl program to do? |
Quote:
My guess would be that the server your using at webair does not have the correct moduals loaded because when i tried the revised script posted by the other gfy member it worked fine for me. |
I can resolve this problem for you
icq 48721721 |
make sure the file is saved in UNIX text mode not DOS text mode. the line breaks are different, so you'll get an error for the next 5 lifetimes.
if you made this in notepad or other such program then it will never work because the line breaks are bad. just download and install Crimson Editor (it's a free code editor), open your script in there, goto Document->File Format->Unix and then save and upload it. Crimson even has an upload feature but just your regular FTP. good luck |
that's not the problem, however if you have not got a response yet, you should find professional hosting, try http://www.ehosts.org
where the owners are programmers, so you don' t have these problems |
I believe webair uses FreeBSD and perl is installed under /usr/local/bin/perl ... It's been a while since I had a webair account though so I could be wrong.
|
Quote:
I need a script that can return me the region of an given IP address. I send the IP and I should get these parameters back: $region = $k->param( "region" ); $city = $k->param( "city" ); $country = $k->param( "country" ); and print them on my screen... Of course, if this works.. I will integrate it in my payment system. I am trying to use Maxmind.com's service. Their customer service has been bad until now. I wrote 5 Emails, got 5 answers but it looks like they don't read my Emails and keep asking me the same questions : What error messages, Wich version of our script are you running ? Gee... Just read my god damn Emails and you have all the informations ! I haven't found another company wich offers the same service until now or I would have switched long ago ! I just got a webair tech checking all my Perl modules needed to run the script and they are all there and up to date. Damn ! I only get "Internal error messages " I don't even get errors in my Apache log file and the command : use CGI::Carp qw(fatalsToBrowser); doesn't work. I don't know what to do. I don't have a clue on what to do and I have been working on this for 48 hours now. I am getting frustrated... |
ok.. I finally got some error messages on my screen.
Here you are : I have 10 lines like this one with different Global symbol errors : Global symbol "$q" requires explicit package name at /www/virtual/jonjovi/www.domain.com/cgi-bin/example2.pl line 9. |
Is perl working at all on that host? Just make sure by creating a real simple 'hello world' cgi script first..
|
and you really really really should turn on 'use strict;' and initialize all your variables with the my() function...
|
Quote:
Of course ! :winkwink: I have like dozens of scripts working. |
Quote:
here is the new script : ############################# #!/usr/bin/perl -wT use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use diagnostics; use HTTP::Request::Common qw(POST); use LWP::UserAgent; $q = CGI->new(); $ua = LWP::UserAgent->new(); $req = POST 'http://maxmind.com:8010/b', [l => "hgfdgghhh", i => "69.70.92.38" ]; $k = new CGI($ua->request($req)->content); $region = $k->param( "region" ); $city = $k->param( "city" ); $country = $k->param( "country" ); print "Content-type: text/html\n\n"; print "$region\n"; exit; ################################ |
Should be:
############################# #!/usr/bin/perl -wT use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use diagnostics; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $q = CGI->new(); my $ua = LWP::UserAgent->new(); my $req = POST 'http://maxmind.com:8010/b', [l => "hgfdgghhh", i => "69.70.92.38" ]; my $k = new CGI($ua->request($req)->content); my $region = $k->param( "region" ); my $city = $k->param( "city" ); my $country = $k->param( "country" ); print "Content-type: text/html\n\n"; print "$region\n"; exit; |
Quote:
Internal server error... :( |
If you want you could give me a username and password to your ssh and server. I will try to fix it then. You may trust me.
Does it somewhere on maxmind say what your perl program needs to do, what parameters it has to pass and receive? If so, I could get you something going in minutes - free. |
FuqALot helped me before with similar shit... Good guy.
|
Quote:
|
Not sure if this will work, but try using:
#!/usr/local/bin/perl -wT instead of: #!/usr/bin/perl -wT |
it's been 3 days, and you are still looking for someone to fix the problem? Offer a few bucks, and i'm sure someone will hook it up in no time...
|
A: sounds to me like you turned on strict and don't know what it means, and B: did you try the perl -e trick above to make sure you modules are installed?
|
| All times are GMT -7. The time now is 03:33 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123