Colin's how to anonymous FTP through a firewall page


So you want to anonymous FTP through a firewall and have been told that you can't?  Think again.

It's easy really - you can do this through FTP-PM, using REXX and also FTP from the command line.

For all of these routes, you will need the following information:-

1) The IP address of the name of your FTP firewall
2) The address of the ftp site (obviously)
3) The userid required to logon to the remote ftp site (usually anonymous)
4) the password required to verify your userid to the remote ftp site (usually an email address)

Let's look at REXX first of all - this is my favourite way.  The command file given is a quick and dirty solution - not pretty but it does the job.  Explanations are in the code.  The full API is documented in x:\TCPIP\HELP\RXFTP.INF

/* REXX */
/* Get files from IBM */
/* Load FTP API for REXX */
rc = RxFuncAdd("FtpLoadFuncs","rxFtp","FtpLoadFuncs")
/* Say return code from loading API - should be zero */
say "RxFuncAdd err "rc
rc = FtpLoadFuncs()
say "FtpLoadFuncs err "rc
/* Syntax is ip address or name of your FTP firewall, userid at remote ftp site, password */
/* at remote site.  Remember to enclose them in quotes, unless you're using an IP address */
/* which should not have quotes */
rc = FtpSetUser('ftp.local.firewall','anonymous@ftp.software.ibm.com','colin@haynes97.freeserve.co.uk')
/* Say return code - non-zero indicates failure */
say "FtpSetUser err "rc
/* Change directory on remote site */
rc = FtpChDir('ps/products/os2/fixes/v4warp/english-us/xr_m012')
/* Say return code for change directory - non-zero indicates failure */
say "FtpChDir err "rc
/* Get the files */
/* Syntax is local filename including path if required, remote filename, Ascii/Binary */
rc = FtpGet("e:\software\fp12\xr_m012.gdk","xr_m012.gdk","Binary")
/* Say return code for ftpget - non-zero indicates failure */
say "FtpGet err "rc
rc = FtpGet("e:\software\fp12\xr_m012.hdk","xr_m012.hdk","Binary")
/* Say return code for ftpget - non-zero indicates failure */
say "FtpGet err "rc
rc = FtpDropFuncs()
/* Drop FTP API */

Note that if you get a non-zero return code, then the variable FTPERRNO will be set to a more specific value (with the exception of FtpSetUser() and FtpSetBinary() which only give you a return code of 0 for not valid and 1 for valid - confused?, you should be), pointing you in the direction of the fault, namely:-

  "FTPSERVICE"
       unknown service
  "FTPHOST"
       unknown host
  "FTPSOCKET"
       unable to obtain socket
  "FTPCONNECT"
       unable to connect to server
  "FTPLOGIN"
       login failed
  "FTPABORT"
       transfer stopped
  "FTPLOCALFILE"
       problem opening local file
  "FTPDATACONN"
       problem initializing data connection
  "FTPCOMMAND"
       command failed
  "FTPPROXYTHIRD"
       proxy server does not support third party transfers
  "FTPNOPRIMARY"
       no primary connection for proxy transfer

Let's look at FTP-PM next.  This is really easy.  You need to drag an FTP-PM template from the templates folder and fill it as follows:-

and on the Authentication tab, as follows:-

with the password field filled in with your email address as in the REXX sample above.

The last method is simply to use the command line.  To do this, type 'ftp ftp.local.firewall'.  When you are logged on there, logon withe the name 'anonymous@ftp.remote.site' and use a password of your email address again.  Typing '?' lists all the available commands.  Remember to type 'bin' before transferring a binary file and 'asc' before a text file.

Email me if you want some more information.

Back to Home Page.

Version 1.0
Date 11th January 2000