FTP HELP

FTP at the command prompt


FTP is typically used to copy files from one computer to another, e.g. to upload your web pages to the web server of your internet provider

Contents :

  1. starting an FTP session
  2. FTP commands
  3. scripting FTP

Starting an FTP session

To start an FTP session with a remote computer, you need to be connected to the internet, or to the computer you want to FTP with. You can use any data-communication software that establishes a TCP/IP connection. You probably already configured a connection with your internet provider or so.

To start an FTP session at the command prompt, you type either

  1. at the command prompt :c:\DOS> ftp [server name or server IP address]

You will then be prompted to log in, i.e. give you user name and password. For anonymous login, you give 'anonymous' as user name, and your e-mail address as password.

FTP commands

ftp
start ftp session

help
display list of ftp commands

help [command] or ? [command]
display help about this [command]

remotehelp
get help from remote server

open [server]
connect to remote server

user
send (new) user information, e.g. send user name for login

get [file]
download file

receive
download file

mget
download multiple files

put [file]
upload file

send
upload (one) file

mput
upload multiple files e.g. mput *.* : upload all files from current local directory to current remote directory (pwd). You will be asked to confirm every file, so you can skip files, or avoid that local subdirectories are 'uploaded' as files.

cd [directory|path]
change remote working directory

lcd [directory|path]
change local working directory

mkdir [directory name]
create new directory on remote machine

dir [directory]
list contents of remote directory

mdir
list contents of multiple remote directories

ls
nlist contents of remote directory

mls
nlist contents of mulmtiple remote directories

rename
rename file

delete
delete remote file

mdelete
delete multiple files

remdir
remove directory on remote machine

bell
beep when command completed

prompt
turn interactive prompting on/off on multiple commands

verbose
turn verbose mode on/off. verbose mode is something like a 'quiet' mode, reduces the feedback/output to the screen when verbose is ON.

append
append to a file

ascii
transfer as ascii file

binary
transfer as binary files

type
set file transfer type

literal
send arbitrary ftp command

quote
send arbitrary ftp command

status
display current status

glob
toggle meta-character expansion of local file names (sic)

hash
toggle printing '#' for each buffer transferred, i.e. create a kind of progress indicator using ###

debug
start/stop debug mode

trace
turn packet tracing on/off

pwd
print working directory on remote machine

!
escape to the shell (switch from ftp to DOS)

close
terminate ftp session

disconnect
terminate ftp session

bye
terminate ftp session and exit

quit
terminate ftp session and exit

scripting FTP

you can script an FTP session with the command
ftp -s:textfile
where textfile is a textfile that contains the FTP commands you want executed, in the correct order. You'll have to include your user name (Pete) and Password (3122), so that the script can get through the login. Note that anyone who has access to your computer can find this file and read this username and password from the file.

a script may look like this :
	open ftp.africaonline.com
	Pete
	3122
	prompt
	pwd
	lcd c:\mywebsite
	mput *.*
	lcd c:\mywebsite\pictures
	mkdir pictures
	cd pictures
	mput *.*

	[and so on ...]

	bye

note that mput does not upload directories, only files. You need to create the (remote) directories with mkdir, and make sure that the local directory (on your own computer) matches the remote directory (on the remote server) you are uploading to. So to go to an other directory, you have to do both lcd (local) and cd (remote).

This can also be used for a large upload.

With the DOS command DIR C:\MyWebSite /AD /S /B > textfile you create a textfile containing all the directories and subdirectories of C:\MyWebSite. When you edit in cd, lcd and mput *.* for every subdirectory, you have a script to upload a complete website.
the /AD option works in DOS 7.x (Windows 95, 98, ...). It may not be available in earlier DOS versions. I seem to remember there was a /T option for for DIR 'directories only'. Or else there's the THREE command (no longer available in DOS 7.x) to list the directory structure, which can be used in a similar way as DIR /AD. Look up DOS help in the Operating Systems section of The Hacker Library. Here's an elaborate example of an ftp script for DOS

On Linux, scripts can use shell variables and the advanced Unix string manipulation tools in combination with ftp. Here an example of an ftp script for Linux.