473,412 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

connection

hi,
I have a problem connecting to the sites using LWP::UserAgent the code is working fine in command prompt but through cgi in browser it is giving an error:
500 cant connect to :80(unknown error)my code is here:
Expand|Select|Wrap|Line Numbers
  1. #!c:\perl\bin\perl.exe
  2.  
  3. use CGI qw(:standard);
  4. use LWP::UserAgent;
  5. use CGI;
  6.  
  7. my $url="http://search.cpan.org/";
  8.  
  9. print header;
  10.  
  11. require LWP::UserAgent;
  12.  
  13. my $query=new CGI;
  14. my $ua =LWP::UserAgent->new;
  15.  
  16. $ua->env_proxy();
  17.  
  18. $response=$ua->get($url);
  19.  
  20. $conn=$response->content;
  21. print $conn;
  22.  
  23. my $res = $ua->request($conn);
  24.  
  25. #print start_html;
  26. print<<HTML;
  27. <title>info</title>
  28. <body>
  29. HTML
  30.  
  31. print $conn;
  32.  
  33. print "</html></body>";
  34. if ($res->is_success)
  35. {
  36.     print "success";
  37.     print "$conn";
  38.     #print $query->redirect("http://first.server/index.php");
  39. else 
  40. {
  41.         #print $query->redirect("http://second.server/index.php");
  42. }
Thankyou
Sep 26 '06 #1
2 1290
eWish
971 Expert 512MB
You have several issues. You don't need to have 'require LWP::UserAgent' when using 'use LWP::UserAgent;' Also, you need to use either 'use CGI qw(:standard);' or 'use CGI;'

If you had used the CGI::Carp module along with the strict and warnings pragmas you would have been able to detect most of your issues. Read about the difference between use and require.


--Kevin
Nov 19 '07 #2
KevinADC
4,059 Expert 2GB
Also, make sure your firewall (if any) is not blocking.
Nov 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: G-Fit | last post by:
Hello group, I have several servers hosting SQL databases. On each of them, I have several databases. All those databases have the same structure (even those on different servers), only the data...
11
by: pradeep_TP | last post by:
Hi all, I have a few questions that I have been wanting to ask for long. These are all related to ADO.net and specifically to conenction to database. 1) If I have opened a connection to a...
6
by: Chris Szabo | last post by:
I've created a data access layer for a .NET web application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection saying: ...
18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
3
by: fniles | last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like the following: In the main form load I open a connection using a connection string that I stored in a global variable...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.