FTP in DOS
29 Nov 2004 @ 08:47AM

Updated: 28 Jan 2010 @ 08:50AM
This page will give detailed, step-by-step instructions on how to FTP to a website in DOS. It will also detail how to send and retrieve files through DOS FTP. This tutorial is written using Windows2000, which should be directly applicable to WindowsXP as well. I will note differences between Win2k and Win9x (win95, 98, 98se, and ME) so that you should be able to use these instructions for any Windows O/S. However, these differences are very small...the actual FTP program works exactly the same across all Windows operating systems.

Step 1. Command prompt

The first thing that needs to be done is bringing up the command prompt. Start | run | cmd. (for Win9x, it's Start | Run | Command).



Step 2. Initiating the connection

The second step is to initiate the FTP connection. Do that by typing:

ftp [hostname]

where [hostname] is replaced by the customer's PhP server. For instance, if your FTP server were your.ftp.server.here.com, you would do what's shown in the screenshot below.



Step 3. Logging into the server

After hitting the enter key on the above step, you should connect to the FTP server. It will spout off software type and version numbers, then prompt you to log in. The username is the directory name of your web page. This was typically specified by you when you set your webpage up. The password is whatever password you selected for that webpage.



Assuming you get this far (the login worked), everything is working with your login. If you're having issues using some 3rd party program to log in, but can log in through DOS, the issue lies with that program. Examples would be frontpage, ws_ftp, and cuteFTP. However, if you can log in but are having issues transferring files, continue reading.

Step 4. Getting a directory listing

Before attempting any more advanced commands, we're going to pull a listing of what files you currently have in this directory. The command for this is either 'ls' or 'dir'. Both commands should work. Note that your directory contents will differ from what is shown in the screenshot.



Step 5. Sending a file through ftp

Now we are going to go into more advanced features. The first thing to do is find a small file on your computer that you want to transfer. To do this, I would recommend you quit out of the FTP connection (the command is 'quit') so that you're back in DOS again. At this point, do a dir to see what files are in the current directory, and find something small and easy to type.



As you may have noticed, wshnetbs.dll is only about 8KB large. Write that filename down (so you don't forget it), and then log back into the FTP server.



Now you'll need to type the following command:

Send wshnetbs.dll

You should get something similar to this screenshot. If an error occurs, there could be a problem, depending on the error received. We'll get into that next.



If an error was received, we need to know the error. Be sure to document it somewhere...you may need it if you're going to call your provider. However, here are a listing of some errors.

[filename] not found: ... you have mistyped the filename to be sent. This is not a problem with the server. Just try to resend the file.

550 permission denied: ... you do not have sufficient rights to upload the file. This is a problem with how the web page was set up, and needs to be brought to the attention of your ISP/home page provider.

Additional errors may occur. If you receive one not listed about, use a search engine. (google)

Just to reiterate; if the transfer is successful, your web page is working properly. If you are unable to transfer files in another program, the issue is with that program, and not with the service. You will need to talk to the vendor of that particular peice of software.

Step 6. Advanced commands.

More advanced commands are covered here. None of these will probably ever be necessary under normal circumstances, but it's always good to have a greater knowledge then what is typically required. We'll be covering several advanced commands that are regularly used by people who actually use DOS ftp to transfer files.

Receiving a file: The command to retrieve a file from online is the following:

get [filename]

where filename is, of course, a file that exists on the server. We're going to have an example using our favorite dll, wshnetbs.dll.



Changing directories: The command to change directories in your web page is the following:

cd [directoryname]

where directoryname is the name of the directory you want to change to. To back out one directory level, the command is 'cd ..', while getting all the way to your top directory is done with 'cd /'.



The next command we're going to explore is the lcd command. This command changes "local" directories...ie, if you ftp'd from the c:windows directory, you can lcd to anywhere else on your harddrive. The command is:

lcd [directoryname]

where directoryname is the name of the directory you want to change to. The same rules with backing out of directories in cd applies to lcd.



The next thing we're going to learn is how to delete files off the server, through DOS ftp. The command to delete files is 'delete' or 'dele'.



And next, we're going to learn how to make directories. The command to make a new directory follows:

mkdir [directoryname]

where [directoryname] is the name of the directory you wish to create. You can then change into that directory using the cd command.



And now, we're going to go over on how to delete (or remove) a directory. The command for that is:

rm [directoryname]

where [directoryname] is the name of the directory you wish to remove.



That is the end of this quick tutorial. This page has hopefully given you a fairly good, if basic, understanding of commonly used FTP commands.
Comments (0)