FTP problems on windows

I created a script to send a receive event scripts for a pixord video
server.
I created an FTP session class which contains the following def's

def initialize(ip)
        begin
            @serv = Net::FTP.new(ip)

            @serv.login(user=*****,password =*****)
            #get into Sys dir
            @serv.chdir('Sys')

        rescue
            puts "Invalid IP set. ip set as #{ip}\n"
        end
    end

    def get_curr(filename)

       loadfile = @serv.gettextfile("scr00.txt")#get the event file
stored
                                                #in the pixord server

        # change the name of the file to given file name
        File.rename("scr00.txt", filename)

    end

    def put_curr(filename)

        #change name to pixord event name

  begin
        File.rename(filename, "scr00.txt")

  rescue

  puts "file name problem #{filename}\n"

  end
        @serv.puttextfile("scr00.txt")
    end

···

#####################

Everything works fine with my other implimentations (on OSX). However,
when on a windows machine I can not view anything in the server. The
connection is being made though.

To test what was going on I used irb on Windows (I have tried XP and
2000) and entered the following

require 'net/ftp'
ftp = Net::FTP.new(ip)
ftp.login(user=user_var,password=pass_var)

#UP TO HERE OK (I think.. no errror or anything)
ftp.chdir('Sys')

ftp.gettextfile("scr00.txt") #here is where problem occurs

###########END CODE

When I run from a Mac OSX machine I can access fine, but from the
windows machines I am getting "Net:FTPTempError 425 Can't Open Data
Connection"
I am not exactly sure how to deal with this. If they are on different
subnets how do I handle this. I am pretty sure the Mac is also but for
some reason is handling it OK. I am a bit baffled. Any help is
appreciated. Thanks in advance.

-Collin

csjasnoch@wisc.edu wrote:

When I run from a Mac OSX machine I can access fine, but from the
windows machines I am getting "Net:FTPTempError 425 Can't Open Data
Connection"

It's probably a firewall on the Windows machine.

FTP is a multi-connection protocol. When you ask it to transfer a file, it opens a second TCP/IP connection on a random port, and uses that to transfer the data. Obviously this is a problem when the two machines are behind firewalls.

You can choose which machine initiates the connection via a choice of passive FTP vs regular FTP. However, that just chooses who has to open their firewall--either way there's still a random-port connection to deal with.

That's in general; in the case of the Ruby library, I don't recall seeing any option for passive FTP. So in this case, the server is picking a random port > 1024, and trying to open a connection on that port to the client code.

I am not exactly sure how to deal with this.

Don't use FTP unless you have to. It's a really lousy protocol.

Probably the Mac is handling it because it doesn't have quite as severe a firewall as the Windows box (because Macs don't have the same degree of security problems as Windows boxes).

mathew

···

--

Hi,

···

In message "Re: FTP problems on windows" on Tue, 19 Jul 2005 06:55:56 +0900, csjasnoch@wisc.edu writes:

I created a script to send a receive event scripts for a pixord video
server.
I created an FTP session class which contains the following def's

You might need to use passive mode. Try adding

  @serv.passive = true

in your code.

              matz.

Thanks that was it. Just had to set the passive flag to true:)