PATH: Instructional Server> Internet>

An Example of Internet File Transfer with FTP


File Transfer Protocol (FTP) was developed in the early 1970's as the standard method for transferring files of any type from one computer to another on the Internet. Files can be uploaded to or downloaded from FTP Servers (software repositories) using FTP Clients (programs that allow users to interact with the servers). Software developers and web developers depend highly on FTP (or variants). Transfer of their files across the Internet is critical in their work. All programmers and web developers need to learn how to use FTP.

Although sophisticated GUI-based FTP clients such as [FileZilla] (with versions for Linux, Mac, Windows, or [Portable/USB]) have been developed that allow fast and easy drag-and-drop file transfer between Internet computers, it benefits all users to learn how to use a basic character-based FTP client. All modern operating systems provide (at least) a character-based FTP client. This program is often critical to the acquisition and installation of further important software, such as drivers and upgrades. Those who use more than one operating system are pleased to discover that character-based FTP clients are almost identical regardless of platform. For general information about FTP and a detailed list of the optional features offered by character-based FTP clients, review FTP - File Transfer Protocol page on this site.

FTP has one significant weakness - security. The protocol was developed in a time when the Internet was being used primarily by computer professionals or enthusiasts, before the general public and organized crime started using it. As such, the FTP protocol was written to send files and other information (user names, passwords, etc.) as plain text which could be intercepted by determined unauthorized users. In response, a variety of alternative protocols have been developed to add encryption to the normal capabilities of FTP. The most popular of these are:

This document provide examples of using both FTP and SFTP sessions using character-based clients. For more in depth information about these topics, read Understanding Key Differences Between FTP, FTPS and SFTP or perform a web search based on the words: FTP, FTPS, or SFTP.

Anonymous FTP

A distinction exists between using FTP to access files that are publically accessible (a practice known as "Anonymous FTP") and using FTP to access proprietary files that are stored under specific user accounts on host computers. The FTP protocol involves "user authentication", which is the practice of requiring a user name and password to access data. Files can be made publically accessible by creating an "anonymous account" on an FTP server (with a username of literally "anonymous") which accepts as its password the email address of the user. Access is typically restricted to a limited collection of folders and files, and is often also limited to downloading only (although some servers are configured to allow limited uploading to a specific folder which is checked regularly for viruses and copyright compliance). When using ordinary FTP to access files a private user account, users are typically restricted to accessing files in only folders which are part of their account.

Character-based Clients vs. GUI (Graphic User Interface) Clients

The examples on this page show how to use character-based FTP clients to transfer files over the Internet. Readers who are interested in learning alternative procedures using the File Explorer utility in Windows® to perform FTP transfers should read one of the following web pages:

   [Access FTP Sites Natively in Windows 8]
   [Access FTP Sites Natively in Windows 7]
   [Setting up Windows Vista for FTP]
   [Setting up FTP via File Explorer in Windows XP]

EXAMPLES

These examples demonstrate use of the character-based FTP client in Windows (any version), but should work almost the same on any operating system that offers a character-based command prompt. Be aware however that many servers are controlled by operating systems that are case-sensitive, which is true of the IRSC Student Web (Linux) Server. So users must give careful attention to their use of case when typing commands. The information required to connect to an FTP Server is: the server's fully-qualified domain name or IP number, user's account name and password, and any special options that must be used to accomplish the connection. The information required to perform an FTP transfer (upload or download) is: the filename and path to the file to be read and and filename and path to the file to be written. It is also important to know if the file being transferred is a text file or not, as these are transferred differently from non-text files such as: pictures, music, and programs. The method of transfer is called the transfer "mode" (meaning "method of operation"). Text files are transferred using a mode named "ASCII mode". Non-text files are transferred using a mode named "Binary (or Image) mode". Each example below will specific these parameters independently.


Example of Using FTP to Download a File from an Anonymous FTP Site

This example is based on the following specifications for an anonymous user downloading a sample picture file that has been previously posted in the anonymous account on the IRSC Student Web (Linux) Server.

Specific Steps:

  1. From the Windows Desktop, click on Start, then select Run... (or use the "Windows" button Windows Button in combination with the letter "R" - for Run).
  2. A "Run" dialog box should appear in which you can type character-based commands. Type FTP in the "Open:" textbox and click on the OK button.
  3. A black and white command window should appear in which the character-based FTP client is launched. Such clients display the prompt ftp> whenever they are ready for a new command.
  4. Open a connection to the FTP server by typing open irscstudentweb.org and pressing the Enter key. The server should responded (similar to): Connected to irscstudentweb.org
  5. When prompted for "User ... :", enter the username anonymous (all lowercase).
  6. When prompted for "Password:", he entered your email address. (Actually any valid email address will typically be accepted.) You will not see your keystrokes echoed on the screen, so type carefully. You should then see the following messages:
    230 Login successful.
    ftp> 
  7. Examine your connection status with the FTP server to determine the current setting for the transfer mode using the command: stat
    You should see something like:
    Connected to irscstudentweb.org.
    Type: ascii; Verbose: On ; Bell: Off ; Prompting: On ; Globbing: On
    Debugging: Off ; Hash mark printing: Off .
    ftp>
  8. If you do not see Type: ascii; in the status report, change the transfer mode to ASCII using the command: asc
    You should receive a reply like "Switching to ASCII mode".
  9. Switch on the Hash mark printing feature of FTP, which displays the '#' symbol once for every two kilobytes of data transferred, using the command: hash on
    This provides visual feedback like bar chart (made of #'s) showing the progress of any file transfer.
  10. Now query the local operating system (Windows) regarding the current working directory with the command lcd which is short for "local current (or change) directory". Windows will reported your current working folder in a manner similar to the report below.
    Local directory now C:\Users\Owner.
    ftp>
  11. Then command your local operating system to change the current working directory to be the folder on on your memory stick that you want to serve as the destination for your download. In this example, the command would be: lcd F:\projects assuming that your memory stick was labeled as Drive F: on your computer and you had already created a folder named "projects" in its root folder. Windows should report your current working folder to be: F:\projects.
  12. Next, use the dir command to display the directory contents on the server. You should see a list of any files or sub-directories (folders) stored there, including a folder named pub (a folder typically created on Anonymous FTP servers to contain publically accessible files.
  13. Now change to the pub directory using the command: cd pub
  14. Then, use the dir command to display the contents of that server directory. You should see a list of any files or sub-directories (folders) stored there, including a folder named cis1000 which contains the file we plan to copy.
  15. Now change to the cis1000 directory using the command: cd cis1000
  16. Then use the dir command to display the contents of the cis1000 folder on the server.
  17. You are now ready to download the file irsclogo.png from the current working directory on the server to the current working directory (F:\projects) on your memory stick using the command: get irsclogo.png
    Pay close attention to case (lower vs. upper). As the transfer takes place, you should see the message below including a short bar chart constructed from hash marks.
    200 PORT command successful. Consider using PASV.
    150 Ok to send data.
    ##
    226 Transfer complete.
    ftp: 4405 bytes sent in 0.01 Seconds 2205000.00 Kbytes/sec.
    ftp>
  18. At this point, your transfer should be complete. To confirm that, use your FTP client to query the local operating system (Windows) regarding the contents of the current working directory on your computer with the command !dir. (The exclamation point can be used to pass character-based commands that are known by the operating system to its command interpreter for execution.) Windows should then list the contents of the current working folder. You should see the file named irsclogo.png listed.
  19. The only step remaining is to close your connection with the FTP server using the command: close
  20. The server will send a parting message. With your FTP activities complete, terminate the FTP client program with the command: quit

Example of Using FTP to Upload a File to a Private Account

Note: The use of the unsecure FTP protocol to access personal accounts on remote host computers is quickly being replaced by more secure (encrypted) methods, such as SFTP and FTPS mentioned above. This example, demonstrates the use of the SFTP protocol.

This example demonstrates use of the free character-based SFTP client named in Windows (any version), but it should work almost the same on any operating system that offers a character-based command prompt. Be aware however that many servers are controlled by operating systems that are case-sensitive, which is true of the IRSC Student Web (Linux) Server. So users must give careful attention to their use of case when typing commands. The information required to connect to an FTP Server is: the server's fully-qualified domain name or IP number, user's account name and password, and any special options that must be used to accomplish the connection. The information required to perform an FTP transfer (upload or download) is: the filename and path to the file to be read and and filename and path to the file to be written. It is also important to know if the file being transferred is a text file or not, as these are transferred differently from non-text files such as: pictures, music, and programs. The method of transfer is called the transfer "mode" (meaning "method of operation"). Text files are transferred using a mode named "ASCII mode". Non-text files are transferred using a mode named "Binary (or Image) mode". This example is based on the following specifications for a fictitious student named Andy Baker with student number of A12-34-5678 uploading a web page that he has saved on a USB memory stick to his public web folder on the IRSC Student Web (Linux) Server.

Specific Steps:

  1. First, Andy had to acquire the free SFTP client named "PSFTP" (PuTTY SFTP). He navigated to or entered the URL (web address) of the following web page for directions:
    http://www.gibsonr.com/classes/howto/getpsftp.html
  2. After downloading the program file psftp.exe, he saved it to his desktop. He ran the program by simply double-clicking on the icon entitled psftp.exe. When the Windows security warning appeared, Andy clicked the Run button.
  3. A black and white command window appeared in which the character-based SFTP client was launched. Such clients display the prompt psftp> whenever they are ready for a new command. Because no server name was provided when the program was run, an error message is displayed, indicating: psftp: no hostname specified; use "open host.name" to connect.
  4. Andy opened a connection to the SFTP server by typing open irscstudentweb.org and pressing the Enter key. The server responded: login as:
  5. Andy entered his username a12345678 (with first letter lowercase).
  6. When prompted for his password, he entered AB45678 (notice: uppercase letters here). He did not see the keystrokes echoed on the screen, so he typed carefully. He then saw the following messages:
    Remote working directory is /home/a12345678
    psftp> 
  7. Whenever Andy wants to be informed of his current working directory, he can have his SFTP client query his local operating system (Windows) for it with the command pwd which is short for "print (display) working directory".
  8. Andy next commanded his local operating system to change the current working directory to be the folder on his memory stick that contained his web page file using the command lcd F:\projects. Windows reported his current working folder as: New local directory is lcd F:\projects
  9. He then had his FTP client query his local operating system (Windows) regarding the contents of the current working directory with the command !dir. (The exclamation point can be used to pass character-based commands that are known by the operating system to its command interpreter for execution.) Windows listed the contents of his current working folder, in which he saw his file named practice.html listed.
  10. Next, Andy used the dir (without !) command to display the directory contents on the server. He saw any files or sub-directories (folders) stored there, including a folder named cd public_html.
  11. He changed to the public_html directory using the command: cd public_html
  12. He then used the dir command to display the sub-directory's contents on the server. He saw any files or sub-directories (folders) present in that folder.
  13. Andy was now ready to upload his file practice.html from the current working directory (F:\projects) on his memory stick to the current working directory (public_html) on the server using the command: put practice.html
    When the transfer was complete, he saw the message below:
    local:practice.html => remote:/home/a12345678/public_html/practice.html
    psftp>
  14. Andy's transfer was successful. But he was still connected to the server. So he closed his connection with the FTP server using the command: close
  15. With his SFTP activities complete, Andy terminated the SFTP client program with the command: quit

All that was left now was to test whether his web page file could be retreived and rendered by a web browswer. So Andy opened his browser and entered the following web address (corresponding to the location of his public web folder on the student server:

    http://irscstudentweb.org:port/~a12345678/practice.html

The portion of the URL above reading :port may require the inclusion of an Internet "port number" for security purposes. Most websites do not require this because they default to the standard http port number (80). If a port number is required, your instructor will provide that information in class or in your course shell on the . Simply omit the red portion of the URL above for normal servers. Include the given port number (following a colon) for the IRSC Student Web Server.

Notice the presence of the tilde (~) character in the URL above, indicating a path to Andy's public web folder (public_html) on the student server. This is a standard notation used on Linux systems that host web pages beneath the home folders of individual account holders. The path http://irscstudentweb.org/~a12345678/ maps to the user Andy's public_html folder. All web content beneath that point can be reached using a URL that starts with the path http://irscstudentweb.org/~a12345678/.

PATH: Instructional Server> Internet Fundamentals>