JOSHFTP is a reliable FTP client that runs under MS-DOS using the Novell TCP/IP network stack. It lets you transfer files between your MS-DOS machine and a standard FTP server on the network. It is a command line tool, so it is perfect for use in automated batch files.
Sadly, the Novell client has a bug that occasionally and unpredictably makes it crash the whole machine (hard reset required). And the bug seems to happen more often the faster the machine (about twice per day on my 1Ghz Pentium). This is pretty much a deal killer for any system that you need to run unattended.
JOSHFTP.ZIP - Contains the JOSHFTP.EXE executable plus a test batch file.
The JOSHFTP client is very low level. You specify the actual FTP protocol command strings that your want to send to the server. The JOSHFTP program sends each specified command string and then waits for a response. If the response is a success, then it continues, otherwise it quits. To understand the command strings, you'll have to read about the FTP Protocol or just play around with the examples below.
JOSHFTP ip_address ip_port timeout [command_string | transfer_setup | !script_file ] ...
ip_address is the IP address of the FTP server. Could also be the name of the server if you have DNS set up or are using a HOSTS file.
ip_port is the TCP/IP port to connect to. Almost always 21.
timeout is the timeout in seconds to wait for a response to a command.
command_string is a string to send to the FTP server (typically an FTP protocol command). Use quotes around a string that has embedded spaces.
transfer_setup is a local filename preceded by either a '+' (for upload)or a '-' (for download) character that prepares the client for an upcoming file transfer. The filename can be a maximum of 11 characters long.
script_file is the name of a local text file that contains a list of command_strings and transfer_setups.
On exit, JOSHFTP will set the DOS errorlevel to one of the following values...
0 = Success 1 = Novell stack not found 2 = Failure connecting to control socket 3 = Failure reading control socket 4 = Control line response too short 5 = Servered returned 4xx error 6 = Servered returned 332 error 7 = Lolcal file name/direction not specified (+/-) 8 = Data socket already opne when PASV issued 9 = Error parsing address from PASV response 10 = Error parsing port from PASV response 11 = Error connecting data socket 12 = No data channel open yet. Use PASV first.r 13 = Error creating local data file 14 = Error reading from data socket 15 = Error writing to local data file 16 = Error opening local data file 17 = Error reading from local data file 18 = Timeout on socket write 19 = Error writing to data socket 20 = Error writing FTP command to control socket 21 = Error sending FTP command on control socket 22 = Local data filename must be 12 chars or less 23 = Error opening local command file
The most important command strings are...
|USER username||First step in logging into the server.|
|PASS password||Second step logging into the server.|
|CWD directory||Change directory on the server.|
|QUIT||Terminate the connection.|
|PASV||Prepare the host for a data transfer.|
|TYPE A | E | I | L bytesize||You almost always want either 'A' (ASCII) or 'I' (binary)|
|RETR filename||Download filename from the server.|
|STOR filename||Upload to a file named filename on the server.|
|APPE filename||Same as STOR except that the file is appended to if it already exists on the server.|
|RNFR current_name||Rename from current_name on the server (must be followed by a RNTO)|
|RNTO new_name||Rename to new_name on the server.|
|DELE filename||Delete filename on the server.|
|LIST||List current directory on the server. Treat like a file download.|
|NLST [remote_dir]||List files in bare format. Good for generating a list of filenames to later process in a batch file.|
A transfer setup lets the JOSHFTP client know that a data transfer is coming. It tells the client the name of the local file involved with the transfer and the direction of the transfer. You need to specify a transfer setup before any command that uses the data channel (LIST, STOR, RETR, etc).
The format of a transfer setup is either a '+' or a '-' followed by the local filename to be used. The '+' indicates that an existing local file should be uploaded to the server and the '-' indicates that the specified local file should be created and filled with data downloaded from the server. The filename must be less than 12 characters long. The local file is always opened or created in the current local directory.
You can specify any number of command_strings or transfer_setups as needed in any order in an external script file. Each should be on a single line without quotes.
Script files are a handy way to get around the maximum DOS command line length limitation of 128 chars. A script file can be as long as you need.
To log into the josh.com FTP server and download the file TEST.TXT:
JOSHFTP 220.127.116.11 21 5 "USER ftpdemo" "PASS foobar" "CWD /ftpdemo" "PASV" -test.txt "RETR test.txt" "QUIT"
Note that you must always open a data channel (PASV) and set up the filename and direction (-text.txt) before doing a transfer (RETR).
Download the host directory listing into the file DIR.TXT:
JOSHFTP 18.104.22.168 21 5 "USER ftpdemo" "PASS foobar" "PASV" -dir.txt "LIST" "QUIT"
Note that the FTP protocol treats a file listing like any other data transfer.
To upload a local file called ME.JPG on the local machine to the file JOSH.JPG on a (ficticious) server...
JOSHFTP 22.214.171.124 21 5 "USER test" "PASS test" "TYPE I" "PASV" +me.jpg "STOR josh.jpg" "QUIT"
Note that you must switch from ASCII to image mode (TYPE I) before transfering binary data. Also note that the transfer setup gives the name for the local file, while the STOR command that is sent to the server give the filename it should use.
Also note that this is just an example and will not work if you actually type it in. You'll need to use an FTP server that gives write permision in order to upload files.
The current version only supports "passive mode" data transfers (no PORT command). This should not be much of a problem since pretty much all FTP servers today accept pasive connections in order to be able to support clients with NATed IP addresses.
Q: Is source code available?
A: Yes. Let me know why you want it and what you are going to do with it and we'll work something out.
Q: The timeout doesn't seem to control how long it waits on
A: To reduce the time it takes for an inital connection to abort, add the line...
...to your NET.CFG file.
Q: How much does JOSHFTP cost?
A: JOSHFTP is free for non-comercial use. I do ask that you do not redistribute it- instead, please send people to this webpage so they can download it themselves. It would also be great if you could send an email to me at the support address below so that I can let you know about any updates to the program.
If you want to use JOSHFTP in a commercial application, let me know and we can work something out.
For support, please email me at...