Solved

500 Can't connect to xtra.co.nz:80 (Bad protocol 'tcp') - Works on Command line but not via the browser

Posted on 2003-11-11
10
1,074 Views
Last Modified: 2010-10-05
I have a little bit of a funny one here for you: (It's not that funny for me though!!)

If I run this perl file from my command line it works but if I run it via a cgi-bin directory on my browser I get an error (CODE and ERROR below).

I've checked my protocol file and it has the following (included below). - As far as I can see that is fine. (C:\WINNT\system32\drivers\etc\protocol).

I've tried it on an XP machine and a Win 2000 machine.

Does anyone know why? or do you have another way to read in the contents of a web page?

Thanks in advance



#MY PROTOCOL FILE
ip       0     IP       # Internet protocol
icmp     1     ICMP     # Internet control message protocol
ggp      3     GGP      # Gateway-gateway protocol
tcp      6     TCP      # Transmission control protocol
egp      8     EGP      # Exterior gateway protocol
pup      12    PUP      # PARC universal packet protocol
udp      17    UDP      # User datagram protocol
hmp      20    HMP      # Host monitoring protocol
xns-idp  22    XNS-IDP  # Xerox NS IDP
rdp      27    RDP      # "reliable datagram" protocol
rvd      66    RVD      # MIT remote virtual disk


#THE CODE

use HTTP::Request;
require LWP::UserAgent;
my $req = HTTP::Request->new(GET => 'http://xtra.co.nz/index.html');

print "Content-Type: text/html\n\n";
print "@INC";

my $ua = LWP::UserAgent->new(env_proxy => 1, keep_alive => 1, timeout => 30,);
#$ua->proxy(http  => 'http://myProxies.com');

$response = $ua->request($req);
if ($response->is_success) {
      print "WORKED";
      print $response->content;
} else {
      print "NOT WORKED";
      print $response->error_as_HTML;
}

#BROWSER OUTPUT:
E:/perl/lib E:/perl/site/lib .NOT WORKED
An Error Occurred
500 Can't connect to xtra.co.nz:80 (Bad protocol 'tcp')

#COMMAND LINE OUTPUT
Content-Type: text/html

E:/perl/lib E:/perl/site/lib .WORKED
<THE HTML FROM THAT SITE>
0
Comment
Question by:mailBoy2
10 Comments
 
LVL 2

Expert Comment

by:ultimatemike
ID: 9724027
Do you have the script set as executable by the webserver?
0
 
LVL 5

Expert Comment

by:dc197
ID: 9724180
Hi
I had a similar problem, the PPM would not download anything and told me I had a "bad protocol TCP".

I fixed it by uninstalling TCP/IP and reinstalling it:

Right click My Network Place, Properties, LAN, right click, properties, Internet Protocol, Uninstall.
Reboot.
Then do the same but install it.

Weird but did the trick.
Daniel
0
 
LVL 2

Author Comment

by:mailBoy2
ID: 9725304
Sorry I've tried this too.
0
 
LVL 2

Author Comment

by:mailBoy2
ID: 9725328
ultimatemike - Is there a trick to this at all as I'm running it on a Windows box. I know how to do it on a UNIX one.

I've configured Apache Tomcat's web.xml to accept a cgi-bin directory, and I can run basic test scripts like hello world etc.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:ultimatemike
ID: 9725526
Have you followed the instructions here?


http://jakarta.apache.org/tomcat/tomcat-5.0-doc/cgi-howto.html
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 9727307
I've just cut and pasted the above code into an Indigo Perl Apache webserver setup, and it works fine both from the command line and the browser. (This is on a Win XP system).

I would suggest that if it works fine from the command line, but not from the server, then the error is with the configuration file. The clasic problem in this situation, is that the webserver may be setup not to accept requests from localhost, therefore you need to access the server via 192.168.*.* or whtever?

Can we confirm that you are running this under a Tomcat (Java) server rather than an Apache (More common server)?



0
 
LVL 2

Author Comment

by:mailBoy2
ID: 9733529
ultimatemike - Yeah I have checked followed them - that exact page actually.

pjedmond - To get it to run did you set any permissions for the file? How did you do this?
I'm running Jakarta Tomcat 4.0.6.

Would proxies and / or firewalls play a part in this - Given that it works fine from the command line?
0
 
LVL 2

Author Comment

by:mailBoy2
ID: 9738074
Now worth 280 points as it's not going to be as straight forward as I thought.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9831868
PAQed, with points refunded (280)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl string replace for refred url 9 59
Perl DBI Transactions Using Custom Module 7 45
Union rows in array that have common elements 2 89
Perl string filter 5 74
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now