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

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

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


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;

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

Content-Type: text/html

E:/perl/lib E:/perl/site/lib .WORKED
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you have the script set as executable by the webserver?
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.
Then do the same but install it.

Weird but did the trick.
mailBoy2Author Commented:
Sorry I've tried this too.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

mailBoy2Author Commented:
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.
Have you followed the instructions here?

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)?

mailBoy2Author Commented:
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?
mailBoy2Author Commented:
Now worth 280 points as it's not going to be as straight forward as I thought.
PAQed, with points refunded (280)

E-E Admin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.