The DOS FTP command

The batch file

First make a batch file to call the ftp command. Call it, say, userpage.bat and add the following two lines:

     @echo off
     ftp -s:c:\batch\userpage.ftp

This means call the Windows ftp program with the source code (or ftp commands) in the file c:\batch\userpage.ftp.

The text file userpage.ftp can be called any name and be put into any convenient directory, but in this example both the batch file and the input data will be in the same directory (c:\batch) and be listed next to each other in a dir listing. That's just an easy way to remember where they are.

The command file

The data in this file consist of ftp commands and automatic inputs to ftp requests from your ISP (namely username and password). This means, unfortunately, that the file will contain your password in clear text.

There are several ways around that. One is to write a program which creates the ftp file from an encrypted source and then securely erases it afterwards. NOT EASY.

The first command will be to open the connection to your ISP with the open command, using the iprimus site as an example:

     open home.iprimus.com.au

Specify the username alone on the next line:

     bobb777

The password goes on the next line:

     12345678

Add put commands if you are uploading files, or get commands if you are reading files from the web-site. An example might be:

     put c:\home\index.htm
     put c:\home\main.css

If you have data in other directories, you can change directories on the ISP with the cd command, for example:

     cd images

Then upload to that directory with another put command:

     put pcb.jpg

If you need other changes in directory use the ".." prefix to go up one level and then to another directory (just like DOS), for example:

     cd ..\data

Then maybe put another file up:

     put pcbprog.zip

Finally exit with the bye command:

     bye

Manual mode

At a DOS prompt, just enter the command ftp. Type the open command and your ISP will then issue the username and password prompts. The first will echo as you type, but the other will not (phew).

The remaining commands are as above, namely the put, get, cd and finally the bye commands.

To see what other commands are available, just type help or ?.

     >ftp
     ftp> help
     Commands may be abbreviated.  Commands are:

     !               delete          literal         prompt          send
     ?               debug           ls              put             status
     append          dir             mdelete         pwd             trace
     ascii           disconnect      mdir            quit            type
     bell            get             mget            quote           user
     binary          glob            mkdir           recv            verbose
     bye             hash            mls             remotehelp
     cd              help            mput            rename
     close           lcd             open            rmdir
     ftp>

Help on individual commands is also available:

     ftp> help lcd
     lcd             Change local working directory
     ftp>