Linux Unleashed, Third Edition:Setting Up an FTP and Anonymous FTP Site
-->
Previous
Table of Contents
Next
Transferring files is the whole point of FTP, so you need to know how to retrieve a file from the remote system, as well as how to put a new file there. When you have moved through the remote systems directories and found a file you want to transfer to your local system, use the get command. This is followed by the filename. For example:
get soundcard_driver
transfers the file soundcard_driver from the remote machine to the current directory on your local machine. When you issue a get command, the remote system will transfer data to your local machine and display a status message when it is completed. There is no indication of progress when a large file is being transferred, so be patient. (Most versions of FTP allow you to use the hash option, which displays pound signs every time a kilobyte of information has been transferred. This can be used to show that the transfer is underway, but it doesnt offer a time to completion.)
FTP> get file1.txt
200 PORT command successful.
150 BINARY data connection for FILE1.TXT (27534 bytes)
226 BINARY Transfer complete.
27534 bytes received in 2.35 seconds (12 Kbytes/s).
If you want to transfer a file the other way (from your machine to the remote, assuming you are allowed to write to the remote machines file system), use the put command in the same way. The command:
put comments
transfers the file comments from your current directory on the local machine (you can specify full pathnames) to the current directory on the remote machine (unless you change the path).
The commands get (download) and put (upload) are always relative to your home machine. You are telling your system to get a file from the remote and put it on your local machine or to put a file from your local machine onto the remote machine. (This is the exact opposite of telnet, which has everything relative to the remote machine. It is important to remember which command moves in which direction or you can overwrite files accidentally.)
The quotation marks around the filenames in the preceding examples are optional for most versions of FTP, but they do prevent shell expansion of characters, so its best to use them. For most files, the quotation marks are not needed, but using them is a good habit to get into.
Some FTP versions provide a wildcard capability using the commands mget and mput. Both the FTP get and put commands usually transfer only one file at a time, which must be completely specified (no wildcards). The mget and mput commands enable you to use wildcards. For example, to transfer all the files with a .doc extension, issue the command:
mget *.doc
You will have to try the mget and mput commands to see if they work on your FTP version. (Some FTP get and put commands allow wildcards, too, so you can try wildcards in a command line to see if they work, instead.)
FTP allows file transfers in several formats, which are usually system dependent. The majority of systems (including Linux systems) have only two modes: ASCII and binary. Some mainframe installations add support for EBCDIC, while many sites have a local type that is designed for fast transfers between local network machines (the local type may use 32- or 64-bit words).
The difference between the binary and ASCII modes is simple. Text transfers use ASCII characters separated by carriage returns and new-line characters. Binary mode allows transfer of characters with no conversion or formatting. Binary mode is faster than text and also allows for the transfer of all ASCII values (necessary for non-text files). FTP cannot transfer file permissions because these are not specified as part of the protocol.
Linux FTP provides two modes of file transfer: ASCII and binary. Some systems automatically switch between the two when they recognize a file is binary format, but you shouldnt count on the switching unless youve tested it before and know it works. To be sure, it is a good idea to manually set the mode. By default, most FTP versions start up in ASCII mode, although a few start in binary.
Note: Make sure you use the right mode.The biggest mistake most users make is to transfer binary files by using ASCII mode. It doesnt matter that much if you send ASCII files through binary mode, but unless you like garbage on your screen, make sure you toggle binary mode when you need it!
To set FTP in binary transfer mode (for any executable file or file with special characters embedded for spreadsheets, word processors, graphics, and so on), type the command
binary
You can toggle back to ASCII mode with the command ascii. Because you will most likely be checking remote sites for new binaries or libraries of source code, it is a good idea to use binary mode for most transfers. If you transfer a binary file in ASCII mode, it will not be usable on your system.
ASCII mode includes only the valid ASCII characters and not the 8-bit values stored in binaries. Transferring an ASCII file in binary mode does not affect the contents except in very rare instances.
To quit FTP, enter the command quit or exit. Both will close your session on the remote machine and then terminate FTP on your local machine. Users have a number of commands available within most versions of FTP. The following list outlines the ones most frequently used:
ascii
Switches to ASCII transfer mode
binary
Switches to binary transfer mode
cd
Changes directory on the server
close
Terminates the connection
del
Deletes a file on the server
dir
Displays the server directory
get
Fetches a file from the server
hash
Displays a pound character for each block transmitted
help
Displays help
lcd
Changes directory on the client
mget
Fetches several files from the server
mput
Sends several files to the server
open
Connects to a server
put
Sends a file to the server
pwd
Displays the current server directory
quote
Supplies an FTP command directly
quit
Terminates the FTP session
Previous
Table of Contents
Next
Wyszukiwarka
Podobne podstrony:
mbdch20 787781 784mbdch20 784787 W04 Łączność modemowa787 789index (787)ReadMe (784)787 OPCEssentials of Maternity Newborn and Women s Health 3132A 31 p782 784787 W08 CAN779 784Satyryczna prawda o szlachcie polskiej w twórczości I K~784demo cgi 784787 Radiomodemy Instrukcja787 W06 Profibus787 W11 OPCwięcej podobnych podstron