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

📄 571-573.html

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

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Using SLIP and PPP</TITLE>

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

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

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

<!--IMPRINT=Que//-->

<!--CHAPTER=29//-->

<!--PAGES=571-573//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="568-570.html">Previous</A></TD>

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

<TD><A HREF="573-575.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>This <TT>chat</TT> script makes <TT>chat</TT> fail if it receives <TT>NO CARRIER</TT> or <TT>BUSY</TT> at any point during the script. <TT>chat</TT> recognizes a number of character and escape sequences, as outlined in Table 29.5.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 29.5</B> Character and Escape Sequences Recognized by <TT>chat</TT>

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="25%" ALIGN="LEFT">Sequence

<TH WIDTH="75%" ALIGN="LEFT">Description

<TR>

<TH COLSPAN="2"><HR>

<TR>

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

<TD>Used as a reply string, this makes <TT>chat</TT> send a break to the modem. This special signal normally causes the remote host to change its transmission speed.

<TR>

<TD><TT>&#145;&#146;</TT>

<TD>Sends a null string with a single carriage return.

<TR>

<TD><TT>\b</TT>

<TD>The backspace character.

<TR>

<TD VALIGN="TOP"><TT>\c</TT>

<TD>Suppresses the newline sent after a reply string and must be at the end of the reply string.

<TR>

<TD><TT>\d</TT>

<TD>Makes <TT>chat</TT> wait for one second.

<TR>

<TD><TT>\K</TT>

<TD>Another means of specifying a break signal.

<TR>

<TD><TT>\n</TT>

<TD>Sends a newline character.

<TR>

<TD><TT>\N</TT>

<TD>Sends a null character.

<TR>

<TD><TT>\p</TT>

<TD>Pauses for 1/10th of one second.

<TR>

<TD><TT>\q</TT>

<TD>Prevents the string it&#146;s included in from showing in the syslog file.

<TR>

<TD><TT>\r</TT>

<TD>Sends or expects a carriage return.

<TR>

<TD><TT>\s</TT>

<TD>Sends or expects a space character.

<TR>

<TD><TT>\t</TT>

<TD>Sends or expects a tab character.

<TR>

<TD><TT>\\</TT>

<TD>Sends or expects a backslash character.

<TR>

<TD><TT>\<I>ddd</I></TT>

<TD>Specifies an ASCII character in octal.

<TR>

<TD><TT>^<I>C</I></TT>

<TD>Specifies the control character represented by C.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B>You can use the <TT>abort</TT> string to prevent low-speed calls on your high-speed modem. Configure your modem to return a <TT>CARRIER 14400</TT> string when it makes a connection and add <TT>abort CARRIER 2400</TT> to your <TT>chat</TT> script. This way, <TT>chat</TT> fails if your modem connects at 2400 bps instead of 14400 bps.<HR></FONT>

</BLOCKQUOTE>

<P><FONT SIZE="+1"><B>Using PPP with >chat</B></FONT></P>

<P>The <TT>pppd</TT> program has command-line options that control all aspects of the PPP link. The syntax for the <TT>pppd</TT> command is as follows:</P>

<!-- CODE SNIP //-->

<PRE>

pppd [<I>options</I>] [<I>tty_name</I>] [<I>speed</I>]

</PRE>

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

<P>Table 29.6 describes the most commonly used options.

</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 29.6</B> Frequently Used <TT>pppd</TT> Command-Line Options

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="30%" ALIGN="LEFT">Option

<TH WIDTH="70%" ALIGN="LEFT">Description

<TR>

<TH COLSPAN="2"><HR>

<TR>

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

<TD>Uses the specified device. <TT>pppd</TT> adds /dev/ to the string if needed. When no device is given, <TT>pppd</TT> uses the controlling terminal.

<TR>

<TD><TT>speed</TT>

<TD>Sets the modem speed.

<TR>

<TD VALIGN="TOP"><TT>asyncmap <I>map</I></TT>

<TD>Sets the async character map. This map specifies which control characters can&#146;t be sent through the connection and need to be escaped. The map is a 32-bit hex number where each bit represents a character. The 0th bit (00000001) represents character 0 &#215; 00.

<TR>

<TD><TT>auth</TT>

<TD>Requires the remote host to authenticate itself.

<TR>

<TD VALIGN="TOP"><TT>connect <I>program</I></TT>

<TD>Uses the program or shell command to set up the connection. This is where <TT>chat</TT> is used.

<TR>

<TD><TT>crtscts</TT>

<TD>Uses hardware flow control.

<TR>

<TD><TT>xonxoff</TT>

<TD>Uses software flow control.

<TR>

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

<TD>Makes <TT>pppd</TT> set a default route to the remote host in your kernel routing table.

<TR>

<TD><TT>disconnect <I>program</I></TT>

<TD>Runs the specified program after <TT>pppd</TT> terminates its link.

<TR>

<TD VALIGN="TOP"><TT>escape <I>c1</I> ,<I>c2</I> ,...</TT>

<TD>Causes the specified characters to be escaped when transmitted. The characters are specified by using the ASCII hex equivalent.

<TR>

<TD><TT>file <I>filename</I></TT>

<TD>Reads <TT>pppd</TT> options from the specified file.

<TR>

<TD><TT>lock</TT>

<TD>Uses UUCP-style locking on the serial device.

<TR>

<TD><TT>mru <I>num</I></TT>

<TD>Sets the maximum receive unit to the specified number.

<TR>

<TD><TT>netmask <I>mask</I></TT>

<TD>Sets the PPP network interface netmask.

<TR>

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

<TD>Makes <TT>pppd</TT> wait for a valid connection rather than fail when it can&#146;t initiate a connection immediately.

<TR>

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

<TD>Keeps <TT>pppd</TT> from initiating a connection. <TT>pppd</TT> waits for a connection attempt from the remote host instead.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P>More than 40 other command-line arguments control all aspects of PPP at all levels. Refer to the main page for information about them.

</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>The <TT>pppd</TT> program demands that the file <TT>/etc/ppp/options</TT> exist, even if it&#146;s empty. This file is read by <TT>pppd</TT> and is an excellent place to put options you want <TT>pppd</TT> to use every time it runs.<HR></FONT>

</BLOCKQUOTE>

<P>You can combine <TT>pppd</TT> and <TT>chat</TT> in a number of ways. You can specify all the command-line arguments for both programs on the command line, put the <TT>pppd</TT> options in a file, or put the <TT>chat</TT> script in a file. The following is a simple example with everything on the command line:</P>

<!-- CODE SNIP //-->

<PRE>

$ <B>pppd connect &#145;chat &#147;&#148; ATDT5551234 ogin: linux2 word: be4me&#146; \</B>

<B>/dev/cua1 38400 mru 296 lock debug crtscts modem defaultroute</B>

</PRE>

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

<P>This runs <TT>pppd</TT> with a simple <TT>chat</TT> script that dials a phone number and logs the user linux2 in to the remote host. The device, speed, MRU, and a number of other options are included.</P>

<P>At the other extreme, you can place most of the options for <TT>pppd</TT> in a file and have <TT>chat</TT> read a script file. The following is the call to <TT>pppd</TT> :</P>

<!-- CODE SNIP //-->

<PRE>

pppd /dev/cua1 38400 connect &#145;chat -f linux1.chat&#146;

</PRE>

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

<P>The following lines display the contents of the reference file:

</P>

<!-- CODE SNIP //-->

<PRE>

# Global PPP Options File

mru 296                            # Set MRU value

lock                               # Use UUCP locking

crtscts                            # Use hardware handshaking

modem                              # Use modem control lines

defaultroute                       # Make PPP set up default route

</PRE>

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

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="568-570.html">Previous</A></TD>

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

<TD><A HREF="573-575.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 + -