826-829.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 185 行
HTML
185 行
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Setting up a Gopher Service</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=50//-->
<!--PAGES=826-829//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="824-826.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="829-832.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading8"></A><FONT COLOR="#000077">Setting Up Your Gopher Directories</FONT></H3>
<P>Gopher directories and files are quite simple to set up and follow standard naming conventions for the most part. Before you begin, though, you should know which documents and files are to be provided through Gopher to other users, and you should be able to write a short description of each. (If you don’t know the contents of a file, either read it or get the author to summarize the file for you.) For simplicity, let’s assume you will use only a single directory for all your Gopher documents.
</P>
<P>Begin by changing to the top directory you use for your Gopher directories (which you may have to create if you haven’t already done so). This directory should not be where the Gopher source and configuration files are located, for convenience. Simply choose a useful name and create the directory. For example, to create the Gopher home directory <TT>/usr/gopher/data</TT>, issue a standard <TT>mkdir</TT> command:</P>
<!-- CODE SNIP //-->
<PRE>
mkdir /usr/gopher/data
</PRE>
<!-- END CODE SNIP //-->
<P>Change into your Gopher directory and copy the files you want to make available into it. When you have done that, you can create a descriptive filename for each file (instead of the more obtuse filenames usually used) up to 80 characters long. For example, if you have a filename called <TT>q1.sales</TT>, you may want to rename it to <TT>Company_Sales_1887_Q1</TT> to help users identify the contents a little more easily.</P>
<P>The process for providing better filenames is to first create a <TT>.cap</TT> directory under your Gopher main directory (such as <TT>/usr/gopher/data/.cap</TT>). For each file in the main directory, you want to create a file in the <TT>.cap</TT> directory with the same name, but with a name and number. For example, suppose you have a file called <TT>q1.sales</TT> in <TT>/usr/gopher/data</TT>. In <TT>/usr/gopher/data/.cap</TT> you would create a file with the same name, <TT>q1.sales</TT>, which has the following contents:</P>
<!-- CODE SNIP //-->
<PRE>
Name=Company Sales for the First Quarter, 1887
Numb=1
</PRE>
<!-- END CODE SNIP //-->
<P>The <TT>Name</TT> entry can have spaces or other special symbols in it because it is echoed as a complete string. The <TT>Numb</TT> entry is for the location of the entry on your Gopher menu. For example, suppose you had the preceding entry and two other files, shown by using <TT>cat</TT> to display their contents:</P>
<!-- CODE //-->
<PRE>
$ cat q1.sales
Name=Company Sales for the First Quarter, 1887
Numb=1
$ cat q2.sales
Name=Company Sales for the Second Quarter, 1887
Numb=2
$cat q3.sales
Name=Company Sales for the Third Quarter, 1887
Numb=3
</PRE>
<!-- END CODE //-->
<P>When these entries are displayed in a Gopher menu they look like this:
</P>
<!-- CODE SNIP //-->
<PRE>
1. Company Sales for the First Quarter, 1887
2. Company Sales for the Second Quarter, 1887
3. Company Sales for the Third Quarter, 1887
</PRE>
<!-- END CODE SNIP //-->
<P>The order of filenames in the <TT>.cap</TT> directory doesn’t matter, but you shouldn’t have the same <TT>Numb</TT> entry more than once.</P>
<P>An alternative to using the <TT>.cap</TT> directory approach (which allows for easy addition of new files) is to use a single master file for each document you are making available. This file goes in your Gopher top directory and is called <TT>.names</TT>. Here’s the <TT>.names</TT> file for the same three files just mentioned:</P>
<!-- CODE //-->
<PRE>
$ cd /usr/gopher/data
$ cat .names
# My Gopher main .names file
Path=./q1.sales
Name=Company Sales for the First Quarter, 1887
Numb=1
Path=./q2.sales
Name=Company Sales for the Second Quarter, 1887
Numb=2
Path=./q3.sales
Name=Company Sales for the Third Quarter, 1887
Numb=3
</PRE>
<!-- END CODE //-->
<P>As you can see, this format contains the same information but adds the filename (which was not needed in <TT>.cap</TT> since the filenames were the same). One advantage to using a <TT>.names</TT> file is that you can reorder your menu entries much more easily because you only have one file to work with instead of several. Also, the <TT>.names</TT> file enables you to add an abstract describing the file. For example, you could have the following entry in a <TT>.names</TT> file:</P>
<!-- CODE SNIP //-->
<PRE>
Path=./gopher
Name=How to Set up A Gopher Service
Numb=16
Abstract=This document shows the steps you need to take to
set up a Gopher service.
</PRE>
<!-- END CODE SNIP //-->
<P>You can get a little fancier with Gopher and have a menu item lead to another menu or to another machine entirely. This is done with links, controlled by a link file, which ends with <TT>.link</TT>. A <TT>.link</TT> file has five pieces of information in it, in the same format as this example:</P>
<!-- CODE SNIP //-->
<PRE>
Name=More Sales Info
Type=1
Port=70
Path=/usr/gopher/data/more_sales
Host=wizard.tpci.com
</PRE>
<!-- END CODE SNIP //-->
<P>The <TT>Name</TT> entry is what a user sees on the Gopher menu and can be any type of description you want, regardless of what else is in the link file. The <TT>Type</TT> field has a number showing the type of document the file links to. The following are all valid numbers:</P>
<CENTER>
<TABLE WIDTH="90%"><TR>
<TD WIDTH="20%"><TT>0</TT>
<TD WIDTH="80%">Text
<TR>
<TD><TT>1</TT>
<TD>Directory
<TR>
<TD><TT>2</TT>
<TD>CSO name server
<TR>
<TD><TT>7</TT>
<TD>Full text index
<TR>
<TD><TT>8</TT>
<TD>Telnet session
<TR>
<TD><TT>9</TT>
<TD>Binary
<TR>
<TD><TT>h</TT>
<TD>HTML file
<TR>
<TD><TT>I</TT>
<TD>Image file
<TR>
<TD><TT>M</TT>
<TD>MIME file
<TR>
<TD><TT>s</TT>
<TD>Sound file
</TABLE>
</CENTER>
<P>These types are the same as the list shown earlier in this chapter for the types of files Gopher supports, although it’s a little shorter here.
</P>
<P>The <TT>Port</TT> field is the port for a connection to a remote system (if that’s where the link leads), and the <TT>Path</TT> field is where the file is on the local or remote server. The <TT>Host</TT> field, not surprisingly, is the name of the host the file resides on. If you are setting up a link to another machine via FTP or WAIS, you need to specify the path to include the service name and any arguments. For example, if your Gopher menu leads users to a file on another machine through FTP, your link file may look like this:</P>
<!-- CODE SNIP //-->
<PRE>
Name=More Sales Info
Type=1
Port=+
Path=ftp:chatton.bigcat.com@/usr/gopher/cats
Host=+
</PRE>
<!-- END CODE SNIP //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="824-826.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="829-832.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?