⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 784-787.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Setting Up an FTP and Anonymous FTP Site</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=48//-->

<!--PAGES=784-787//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="781-784.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="787-789.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>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 system&#146;s directories and found a file you want to transfer to your local system, use the <TT>get</TT> command. This is followed by the filename. For example:</P>

<!-- CODE SNIP //-->

<PRE>

get &#147;soundcard_driver&#148;

</PRE>

<!-- END CODE SNIP //-->

<P>transfers the file <TT>soundcard_driver</TT> from the remote machine to the current directory on your local machine. When you issue a <TT>get</TT> 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 <TT>hash</TT> 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 doesn&#146;t offer a time to completion.)</P>

<!-- CODE SNIP //-->

<PRE>

FTP&gt; get &#147;file1.txt&#148;

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).

</PRE>

<!-- END CODE SNIP //-->

<P>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 machine&#146;s file system), use the <TT>put</TT> command in the same way. The command:</P>

<!-- CODE SNIP //-->

<PRE>

put &#147;comments&#148;

</PRE>

<!-- END CODE SNIP //-->

<P>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).

</P>

<P>The commands <TT>get</TT> (download) and <TT>put</TT> (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 <TT>telnet</TT>, 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.)</P>

<P>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 it&#146;s best to use them. For most files, the quotation marks are not needed, but using them is a good habit to get into.</P>

<P>Some FTP versions provide a wildcard capability using the commands <TT>mget</TT> and <TT>mput</TT>. Both the FTP <TT>get</TT> and <TT>put</TT> commands usually transfer only one file at a time, which must be completely specified (no wildcards). The <TT>mget</TT> and <TT>mput</TT> commands enable you to use wildcards. For example, to transfer all the files with a <TT>.doc</TT> extension, issue the command:</P>

<!-- CODE SNIP //-->

<PRE>

mget *.doc

</PRE>

<!-- END CODE SNIP //-->

<P>You will have to try the <TT>mget</TT> and <TT>mput</TT> commands to see if they work on your FTP version. (Some FTP <TT>get</TT> and <TT>put</TT> commands allow wildcards, too, so you can try wildcards in a command line to see if they work, instead.)</P>

<P>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).</P>

<P>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.</P>

<P>Linux&#146; 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 shouldn&#146;t count on the switching unless you&#146;ve 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.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Note:&nbsp;&nbsp;</B><BR>Make sure you use the right mode.<P>The biggest mistake most users make is to transfer binary files by using ASCII mode. It doesn&#146;t 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!<HR></FONT>

</BLOCKQUOTE>

</P>

<P>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</P>

<!-- CODE SNIP //-->

<PRE>

binary

</PRE>

<!-- END CODE SNIP //-->

<P>You can toggle back to ASCII mode with the command <TT>ascii</TT>. 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.</P>

<P>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.</P>

<P>To quit FTP, enter the command <TT>quit</TT> or <TT>exit</TT>. 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:</P>

<CENTER>

<TABLE WIDTH="90%"><TR>

<TD WIDTH="25%" ALIGN="LEFT"><TT>ascii</TT>

<TD WIDTH="75%" ALIGN="LEFT">Switches to ASCII transfer mode

<TR>

<TD><TT>binary</TT>

<TD>Switches to binary transfer mode

<TR>

<TD><TT>cd</TT>

<TD>Changes directory on the server

<TR>

<TD><TT>close</TT>

<TD>Terminates the connection

<TR>

<TD><TT>del</TT>

<TD>Deletes a file on the server

<TR>

<TD><TT>dir</TT>

<TD>Displays the server directory

<TR>

<TD><TT>get</TT>

<TD>Fetches a file from the server

<TR>

<TD VALIGN="TOP"><TT>hash</TT>

<TD>Displays a pound character for each block transmitted

<TR>

<TD><TT>help</TT>

<TD>Displays help

<TR>

<TD><TT>lcd</TT>

<TD>Changes directory on the client

<TR>

<TD><TT>mget</TT>

<TD>Fetches several files from the server

<TR>

<TD><TT>mput</TT>

<TD>Sends several files to the server

<TR>

<TD><TT>open</TT>

<TD>Connects to a server

<TR>

<TD><TT>put</TT>

<TD>Sends a file to the server

<TR>

<TD><TT>pwd</TT>

<TD>Displays the current server directory

<TR>

<TD><TT>quote</TT>

<TD>Supplies an FTP command directly

<TR>

<TD><TT>quit</TT>

<TD>Terminates the FTP session

</TABLE>

</CENTER>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="781-784.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="787-789.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -