Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


July 2001

Essential FTP Commands


RSS
Subscribe to Windows IT Pro | See More Internet Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Build your file-transfer arsenal

FTP is an important TCP/IP utility that lets you transfer files between systems. One of FTP's most compelling features is its compatibility with many different remote hosts: You can transfer files between remote Windows 2000, Windows NT, and UNIX systems, and even IBM hosts such as the AS/400. To start the text-based FTP utility that's supplied with Win2K and NT, simply enter ftp at the command prompt.

As you begin using the FTP shell, you'll quickly find that the following FTP commands are essential.

10. Help (or ?)—You can issue many FTP commands in multiple ways. Help and the question mark character (?), for example, perform the same function. If you're new to FTP, Help—which displays a list of all the supported FTP commands—is the command to start with. To obtain a brief description of a command, enter ? followed by the command name:

ftp>? open

9. Open—To start an FTP session, you typically use the Open command to connect to a specified FTP server. (The FTP service must be running on the remote host.) After you issue the Open command, the system prompts you for a user ID and password. Many FTP servers let you use an anonymous user ID and blank password to log on. To open a connection to a system named teca2, enter

ftp>open teca2

8. Quit (or Bye)—The Quit command ends any open sessions and exits the FTP shell:

ftp>quit

(To end an open session without terminating the FTP shell, use the Close command.)

7. Pwd—The Pwd command displays the directory that your FTP session is currently connected to on the remote host:

ftp>pwd

6. Ls—The Ls command displays a list of the files and subdirectories that reside in the remote system's current directory. Ls helps you access remote files:

ftp>ls

5. Cd—If the file you're looking for isn't in the remote system's current directory, you can use the Cd command to change directories. If you're connected to a UNIX system, you'll typically need to use a forward slash to identify the remote directory (in this case, the /downloads directory):

ftp>cd /downloads

4. Lcd—The Lcd command changes the current directory on the local system. The current directory is the default location to which the system will write any retrieved files. To change the current local directory to C:\temp, enter

ftp>lcd C:\temp

3. Bin (or Binary)—By default, FTP transfers files in ASCII mode, which is fine for text files. However, to transfer executable and .zip files, you need to use Bin to set the transfer type to binary:

ftp>bin

(Use the Ascii command to set the transfer type back to ASCII.)

2. Put (or Send)—Use the Put command when you want to copy a local file to the remote host's current directory. To send a file named localfile.txt in the C:\temp directory to a remote system, enter

ftp>put C:\temp\localfile.txt

1. Get (or Recv)—You use Get to download files from Internet hosts (or other remote hosts) to the local system's current directory. To retrieve a file named remotefile.txt, enter

ftp>get remotefile.txt

End of Article



Reader Comments
Here are a few more useful FTP commands:
<br><br>
1. Mput - this allows you to upload multiple files at once:
<br><br>
ftp>mput *.txt
<br><br>
2. Mget - the reverse of mput, this lets you download multiple files at once:
<br><br>
ftp>mget *.htm
<br><br>
3. Ascii - the opposite of the Bin command, this tells ftp to download/upload the file as a text based file, which is useful if you've already typed in the Bin command but now wish to change back to ascii:
<br><br>
ftp>ascii
<br><br>
4. Hash - this gives you a progress indicator for your transfer, which is useful when transfering large files. Typing hash at the ftp prompt toggles this feature on and off:
<br><br>
ftp>hash
<br><br>
5. Dir - alone this acts like the LS command, however you can also use it to only show files of a certain type, such as:
<br><br>
ftp>dir *.gif

Jon July 12, 2001


I read Michael Otey's Top 10: "Essential FTP Commands" (July 2001) and want to contribute another tip. One of the most interesting features of the FTP shell is its ability to run in a batch process without user intervention. The exact syntax might vary, but this feature works on Windows 2000, Windows NT, UNIX, and the AS/400. To run FTP as an unattended batch process, create two files: one that contains the FTP command and one that contains the username, password, and any FTP commands you want to execute. Here's an example of the file that contains the FTP command:
<br><br>
ftp ­s:ftpc.txt
<br><br>
And here's ftpc.txt, which holds the script you want to run:
<br><br>
open &lt;servername&gt; [&lt;port&gt;] <br>
&lt;username&gt; <br>
&lt;password&gt; <br>
ls <br>
quit <br><br>

Make sure that you secure ftpc.txt properly because it's stored in plain text. With these simple settings, you can easily automate FTP.

Peter Stehlik September 26, 2001


why can't i use passive mode?

John Osmond March 25, 2004


How can I download a directory and its subdirectories?

Tony Ferro June 28, 2004


When I use the "Append" command for ftp, the file gets appended, the last line of the old file and the first line of the second file get merged into one line.

How do we avoid this?


pdsmatm July 12, 2004 (Article Rating: )


I was searching for commands for AS400 shell. This did not help....

Anonymous User October 25, 2004 (Article Rating: )


Keep Doing What You Are Doing Now

Anonymous User October 26, 2004 (Article Rating: )


Fairly good site

Anonymous User December 03, 2004 (Article Rating: )


SUCK STANDARD INFORMATION! USELESS!

Anonymous User February 16, 2005 (Article Rating: )


nothing great here.

Anonymous User April 07, 2005 (Article Rating: )


 See More Comments  1   2 

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Related Events WinConnections and Microsoft® Exchange Connections

Deep Dive into Windows Server 2008 R2 presented by John Savill

Managing IT Across Multiple Locations

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement