Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > FTP from Perl script on Windows

Reply
Thread Tools

FTP from Perl script on Windows

 
 
Ivan L
Guest
Posts: n/a
 
      09-28-2006

I have tried to use FTP from Perl (not using System() but directly from perl script), and
found out that all the sample programs found on the Internet don't work. Further investigation showed
that there is following error

"Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl line 3."

The part of the perl script that caused this error is:

1.#!/usr/bin/perl -w
2. use Net::FTP;
3. $ftp = Net::FTP->new("Host", Debug => 0) or die "Cannot connect to host: $@";

I use Windows XP SP2 and ActiveState Perl 5.8.7. Also, I have tried to use Windows 2003
server, with the same result.
Can anybody help with this? The FTP server on machine "host" is up and running, using command
line I can FTP without problem.
 
Reply With Quote
 
 
 
 
Sisyphus
Guest
Posts: n/a
 
      09-28-2006

"Ivan L" <> wrote in message
news:Xns984C6A9E0F938ivanlac@213.191.133.136...
>
> I have tried to use FTP from Perl (not using System() but directly from

perl script), and
> found out that all the sample programs found on the Internet don't work.

Further investigation showed
> that there is following error
>
> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl line

3."
>
> The part of the perl script that caused this error is:
>
> 1.#!/usr/bin/perl -w
> 2. use Net::FTP;
> 3. $ftp = Net::FTP->new("Host", Debug => 0) or die "Cannot connect to

host: $@";
>


Can't see anything that should pose a problem (assuming "Host" is replaced
by the valid string for whatever your host really is).

The following works fine for me on Win32:

use warnings;
use Net::FTP;
$ftp = Net::FTP->new("rtfm.mit.edu", Debug => 1)
or die "Cannot connect to host: $@";
$ftp->login('anonymous','anonymous');
$ftp->cwd("/pub/usenet-by-group/");
$ftp->quit;

What does that script produce for you ?

Cheers,
Rob


 
Reply With Quote
 
 
 
 
Ivan L
Guest
Posts: n/a
 
      09-28-2006
Hi Sisyphus,
Unfortunately the result is the same - the message is :
Cannot connect to host: Net::FTP: Bad protocol 'tcp' at C:\PROGRA~1\PERLEX~1\Scripts
\FTPPER~1.PL line 4.
I copied your script and put my host name...

I have all firewalls down and tried to connect to my localhost FTP server to exclude
networking troubles, but it didn't change anything...


"Sisyphus" <> wrote in news:451b90ea$0$11972$afc38c87
@news.optusnet.com.au:

> use warnings;
> use Net::FTP;
> $ftp = Net::FTP->new("rtfm.mit.edu", Debug => 1)
> or die "Cannot connect to host: $@";
> $ftp->login('anonymous','anonymous');
> $ftp->cwd("/pub/usenet-by-group/");
> $ftp->quit;
>


 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      09-28-2006
Ivan L schreef:

> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl
> line 3."


Check out the file "%windir%\system32\drivers\etc\protocol".

--
Affijn, Ruud

"Gewoon is een tijger."


 
Reply With Quote
 
Ivan L
Guest
Posts: n/a
 
      09-28-2006
There is no "%windir%\system32\drivers\etc\protocol" file on my machine.

"Dr.Ruud" <rvtol+> wrote in news::

> Ivan L schreef:
>
>> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl
>> line 3."

>
> Check out the file "%windir%\system32\drivers\etc\protocol".
>


 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      09-28-2006

Quoth l v <>:
> Ivan L wrote:
> > There is no "%windir%\system32\drivers\etc\protocol" file on my machine.
> >
> > "Dr.Ruud" <rvtol+> wrote in

> news::
> >
> >> Ivan L schreef:
> >>
> >>> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl
> >>> line 3."
> >> Check out the file "%windir%\system32\drivers\etc\protocol".

>
> s/protocol/services/


Err.. really not. /etc/protocol ne /etc/services; if you don't
understand the difference between them please don't try to correct those
who do.

Ben

--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'

 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      09-29-2006
l v schreef:
> Ivan L:
>> [attribution corrupted]
>>> [attribution corrupted]


>>>> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at
>>>> ftptest1.pl line 3."
>>>
>>> Check out the file "%windir%\system32\drivers\etc\protocol".

>>
>> There is no "%windir%\system32\drivers\etc\protocol" file on my
>> machine.

>
> s/protocol/services/


The error message was "Bad protocol 'tcp'".
The "services" file contains a list of names for selected port/protocol
combinations.

Ivan, did you understand "%windir%"? It's an environment variable that
has the value "C:\WINNT" on some systems, "C:\Windows" on other systems,
and other values on yet other systems. Go to a command prompt and enter
"set" to get the value on your system.

--
Affijn, Ruud

"Gewoon is een tijger."


 
Reply With Quote
 
Sisyphus
Guest
Posts: n/a
 
      09-29-2006

"Ivan L" <> wrote in message
news:Xns984C73F311E2Bivanlac@213.191.133.136...
> Hi Sisyphus,
> Unfortunately the result is the same - the message is :
> Cannot connect to host: Net::FTP: Bad protocol 'tcp' at

C:\PROGRA~1\PERLEX~1\Scripts
> \FTPPER~1.PL line 4.
> I copied your script and put my host name...
>


It was my intention that you use that script as is. (You should be able to
connect to that ftp server.)

However, I get the feeling that the other respondents might be pushing you
in a more pertinent direction.

Cheers,
Rob


 
Reply With Quote
 
Ivan L
Guest
Posts: n/a
 
      09-29-2006
I know about %windir% environment variable. However, there is no protocol file (or
folder) in the c:\Windows\System32\drivers\etc\ There are, however, several files
named services (services, services01, services02 ...) that happen to be empty.



"Dr.Ruud" <rvtol+> wrote in news::

> l v schreef:
>> Ivan L:
>>> [attribution corrupted]
>>>> [attribution corrupted]

>
>>>>> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at
>>>>> ftptest1.pl line 3."
>>>>
>>>> Check out the file "%windir%\system32\drivers\etc\protocol".
>>>
>>> There is no "%windir%\system32\drivers\etc\protocol" file on my
>>> machine.

>>
>> s/protocol/services/

>
> The error message was "Bad protocol 'tcp'".
> The "services" file contains a list of names for selected port/protocol
> combinations.
>
> Ivan, did you understand "%windir%"? It's an environment variable that
> has the value "C:\WINNT" on some systems, "C:\Windows" on other systems,
> and other values on yet other systems. Go to a command prompt and enter
> "set" to get the value on your system.
>


 
Reply With Quote
 
Ivan Lackic
Guest
Posts: n/a
 
      09-29-2006
I have tried to run your FTP script on some other machine and it worked well. I guess
that it is a matter of some XP setting or some security programs running on the first
machine...
regards,
I.


"Sisyphus" <> wrote in
news:451cc139$0$11971$ u:

>
> "Ivan L" <> wrote in message
> news:Xns984C73F311E2Bivanlac@213.191.133.136...



>> Hi Sisyphus,
>> Unfortunately the result is the same - the message is :
>> Cannot connect to host: Net::FTP: Bad protocol 'tcp' at

> C:\PROGRA~1\PERLEX~1\Scripts
>> \FTPPER~1.PL line 4.
>> I copied your script and put my host name...
>>

>
> It was my intention that you use that script as is. (You should be
> able to connect to that ftp server.)
>
> However, I get the feeling that the other respondents might be pushing
> you in a more pertinent direction.
>
> Cheers,
> Rob
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
Net::FTP problems getting files from Windows FTP server, but not Linux FTP Server. D. Buck Perl Misc 2 06-29-2004 02:05 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57