ftp gurus, please help

geomac

Registered
dual g5 2.0 and 15.2" aluminum powerbook
both on Panther 10.3.8

I am using ftp in an application to connect to a remote server that is behind a satellite internet modem. (fyi, there is some time latency involved due to the satellite connection) the server is running on a windows xp machine behind an airport extreme that is set to forward ports 21 and 20.

If I try to connect through the OS X terminal window, I can actually connect, but when I invoke the "dir" command I get the error "500 'EPSV': command not understood" then the server closes the connection. I searched around a bit and found that a solution to this in the Terminal is to toggle the "passive" mode into "active" mode after making the initial connection. I did this, and it works fine, I can list directories, transfer files etc...

If I un-check the "use passive ftp mode" box in the network proxies preferences and then try to connect from the terminal window without toggling passive to active from the command line, I have the same error out problems, so the Terminal window application and the system preferences are independent.

I would eventually like to use Transmit 3, or Fetch along with some Applescripts to automate some file transfers. Both Transmit, and Fetch error out while getting the file directory listing before I uncheck the "use passive ftp mode" preference. After un-checking it Fetch works fine, Transmit works but only on the second connection attempt, (it errors out on the first attempt).

I can connect to this same server in Passive mode from both OS 9, on a separate OS 9 native machine, and from windows machines running WS_FTP pro.

QUESTIONS

1) What is fundamentally different about OS X ftp protocal that causes the passive mode to fail while both OS 9 (mac) and windows can connect to this server in passive mode.
2) is this possibly related to the server somehow? or is it an OS X problem
3) why can we connect to the server in passive mode, but not complete any other operations, ie. directory listing, file transfer etc....

Thank you very much for any help here and pardon the drawn out description.
 
Welcome to Internet fun 101.

Ports 20/21 are used to make the initial connection, however in Active Mode, the server reconnects with the client on a higher port (>1024) and magic happens.

However, because of Firewalls, this type of connection is not allowed in most cases, and thus, Passive is born. With passive, the client makes the initial connection and then tells the server which higher ports to use and that works well with firewalls, etc.

The odd thing with your situation, I would think it would be the exact opposite. In the fact that passive would be working and giving you the results you are getting while active wouldn't. But anyhow..

Basically... the problem you are having has to do with the HIGH PORTS assigned by the client... possibly you are getting some resistence (ie, ports being blocked, now allowed) from clients using a different range of ports. This would explain why you might get a connection sometimes, while other times not, or not at all.

The solution is to find out which HIGH PORTS your Fetch Client uses since you have success with that client. Take that port range, and apply it to your Transmit client. Both clients should allow you to specify your high port rarnge.

This is not a OS X issue, but just a issue with high ports being used.

Scott
 
Scott,

Thanks for the help, this pretty much makes sense except that if this is not an OS X issue then why do OS 9 and windows ftp attempts work fine in passive mode while those in OS X do not?
 
It all goes back to High Ports defined. The OS X command line ftp obviously uses a different high port setting than applications in OS 9 or Windows command line. Transmit uses it's own, Fetch uses it's own and so does OS X ftp command line app.
 
Ok, that makes sense...

Any idea off the top of your head how to find out what high ports each of the respective applications specifies/defines? I have looked through all the obvious preferences of Fetch and Transmit and have sent inquiry emails to the companies but have not heard back yet. Is there a simple way to monitor what ports the client opens on call back from the server ??

would it be easier to determine what high ports OS X Terminal uses and then apply those to Transmit? How might I specify the ports in Transmit/Fetch... I know these are primarily questions for the application companies but if you are privy to this info without having to spend much time I would appreciate it

thanks again
 
You can use a command in the terminal to discover what is going on network-wise on most unix systems, including Mac OS X.

Launch the terminal, and try this command:
Code:
[kilowatt@hhcp1]$ [b]netstat -nf inet[/b]
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4   63629      0  12.151.114.54.55310    12.151.114.82.5114     ESTABLISHED
tcp4       0      0  12.151.114.54.51176    206.80.25.23.22        ESTABLISHED
tcp4       0      0  12.151.114.54.52977    12.151.114.82.5214     ESTABLISHED
tcp4       0      0  12.151.114.54.54822    205.108.9.96.5190      ESTABLISHED
tcp4       0      0  12.151.114.54.54106    206.82.25.21.6667      ESTABLISHED
tcp4       0      0  127.0.0.1.63885        127.0.0.1.631          CLOSE_WAIT
Basically, identify the ip address of your ftp server in this list, and note that, after the ip address, is the port number. (If you prefer, you can omit the '-n' from the command, and most of the ip addresses and ports will resolve to their more common names.)
 
Back
Top