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

📄 communications.html

📁 Shall高级编程
💻 HTML
📖 第 1 页 / 共 3 页
字号:
> of	      <SPANCLASS="ERRORCODE">0</SPAN>. This can be tested for in a	      script.</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;  HNAME=nastyspammer.com   2&nbsp;# HNAME=$HOST     # Debug: test for localhost.   3&nbsp;count=2  # Send only two pings.   4&nbsp;   5&nbsp;if [[ `ping -c $count "$HNAME"` ]]   6&nbsp;then   7&nbsp;  echo ""$HNAME" still up and broadcasting spam your way."   8&nbsp;else   9&nbsp;  echo ""$HNAME" seems to be down. Pity."  10&nbsp;fi</PRE></TD></TR></TABLE></P></DD><DT><ANAME="WHOISREF"></A><BCLASS="COMMAND">whois</B></DT><DD><P>Perform a DNS (Domain Name System) lookup.	      The <TTCLASS="OPTION">-h</TT> option permits specifying which	      particular <ICLASS="FIRSTTERM">whois</I> server to query. See	      <AHREF="othertypesv.html#EX18">Example 4-6</A> and <AHREF="communications.html#SPAMLOOKUP">Example 15-39</A>.</P></DD><DT><ANAME="FINGERREF"></A><BCLASS="COMMAND">finger</B></DT><DD><P>Retrieve information about users on a	      network. Optionally, this command can display	      a user's <TTCLASS="FILENAME">~/.plan</TT>,	      <TTCLASS="FILENAME">~/.project</TT>, and	      <TTCLASS="FILENAME">~/.forward</TT> files, if present.</P><P>	      <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>finger</B></TT> <TTCLASS="COMPUTEROUTPUT">Login  Name           Tty      Idle  Login Time   Office     Office Phone bozo   Bozo Bozeman   tty1        8  Jun 25 16:59 bozo   Bozo Bozeman   ttyp0          Jun 25 16:59 bozo   Bozo Bozeman   ttyp1          Jun 25 17:07</TT>    <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>finger bozo</B></TT> <TTCLASS="COMPUTEROUTPUT">Login: bozo                             Name: Bozo Bozeman Directory: /home/bozo                   Shell: /bin/bash Office: 2355 Clown St., 543-1234 On since Fri Aug 31 20:13 (MST) on tty1    1 hour 38 minutes idle On since Fri Aug 31 20:13 (MST) on pts/0   12 seconds idle On since Fri Aug 31 20:13 (MST) on pts/1 On since Fri Aug 31 20:31 (MST) on pts/2   1 hour 16 minutes idle No mail. No Plan.</TT> 	      </PRE></TD></TR></TABLE>	    </P><P>Out of security considerations, many networks disable	      <BCLASS="COMMAND">finger</B> and its associated daemon.	          <ANAME="AEN12186"HREF="#FTN.AEN12186">[1]</A>	      </P></DD><DT><ANAME="CHFNREF"></A><BCLASS="COMMAND">chfn</B></DT><DD><P>Change information disclosed by the	      <BCLASS="COMMAND">finger</B> command.</P></DD><DT><ANAME="VRFYREF"></A><BCLASS="COMMAND">vrfy</B></DT><DD><P>Verify an Internet e-mail address.</P><P>This command seems to be missing from newer Linux	      distros.</P></DD></DL></DIV><DIVCLASS="VARIABLELIST"><P><B><ANAME="COMMREMOTE1"></A>Remote Host Access</B></P><DL><DT><ANAME="RXREF"></A><BCLASS="COMMAND">sx</B>, <BCLASS="COMMAND">rx</B></DT><DD><P>The <BCLASS="COMMAND">sx</B> and <BCLASS="COMMAND">rx</B>	      command set serves to transfer files to and from a remote	      host using the <ICLASS="FIRSTTERM">xmodem</I> protocol. These	      are generally part of a communications package, such as	      <BCLASS="COMMAND">minicom</B>.</P></DD><DT><ANAME="RZREF"></A><BCLASS="COMMAND">sz</B>, <BCLASS="COMMAND">rz</B></DT><DD><P>The <BCLASS="COMMAND">sz</B> and <BCLASS="COMMAND">rz</B>	      command set serves to transfer files to and from a remote	      host using the <ICLASS="FIRSTTERM">zmodem</I> protocol.	      <ICLASS="FIRSTTERM">Zmodem</I> has certain advantages over	      <ICLASS="FIRSTTERM">xmodem</I>, such as faster transmission	      rate and resumption of interrupted file transfers.	      Like <BCLASS="COMMAND">sx</B> and <BCLASS="COMMAND">rx</B>,	      these are generally part of a communications package.</P></DD><DT><ANAME="FTPREF"></A><BCLASS="COMMAND">ftp</B></DT><DD><P>Utility and protocol for uploading / downloading	      files to or from a remote host. An ftp session can be automated	      in a script (see <AHREF="here-docs.html#EX72">Example 18-6</A>, <AHREF="contributed-scripts.html#ENCRYPTEDPW">Example A-4</A>, and <AHREF="contributed-scripts.html#FTPGET">Example A-13</A>).</P></DD><DT><ANAME="UUCPREF"></A><BCLASS="COMMAND">uucp</B>, <ANAME="UUXREF"></A><BCLASS="COMMAND">uux</B>, <ANAME="CUREF"></A><BCLASS="COMMAND">cu</B></DT><DD><P><BCLASS="COMMAND">uucp</B>: <ICLASS="FIRSTTERM">UNIX to UNIX	      copy</I>. This is a communications package for	      transferring files between UNIX servers. A shell script	      is an effective way to handle a <BCLASS="COMMAND">uucp</B>	      command sequence.</P><P>Since the advent of the Internet and e-mail,	      <BCLASS="COMMAND">uucp</B> seems to have faded into obscurity,	      but it still exists and remains perfectly workable in	      situations where an Internet connection is not available	      or appropriate. The advantage of <BCLASS="COMMAND">uucp</B>	      is that it is fault-tolerant, so even if there is a service	      interruption the copy operation will resume where it left	      off when the connection is restored.</P><P>---</P><P><BCLASS="COMMAND">uux</B>: <ICLASS="FIRSTTERM">UNIX to UNIX	      execute</I>. Execute a command on a remote system.	      This command is part of the <BCLASS="COMMAND">uucp</B>	      package.</P><P>---</P><P><BCLASS="COMMAND">cu</B>: <BCLASS="COMMAND">C</B>all	      <BCLASS="COMMAND">U</B>p a remote system and connect as a	      simple terminal. It is a sort of dumbed-down version of	      <AHREF="communications.html#TELNETREF">telnet</A>. This command is	      part of the <BCLASS="COMMAND">uucp</B> package.</P></DD><DT><ANAME="TELNETREF"></A><BCLASS="COMMAND">telnet</B></DT><DD><P>Utility and protocol for connecting to a remote host.</P><DIVCLASS="CAUTION"><TABLECLASS="CAUTION"WIDTH="90%"BORDER="0"><TR><TDWIDTH="25"ALIGN="CENTER"VALIGN="TOP"><IMGSRC="common/caution.png"HSPACE="5"ALT="Caution"></TD><TDALIGN="LEFT"VALIGN="TOP"><P>The <ICLASS="FIRSTTERM">telnet</I> protocol	    contains security holes and should therefore probably be	    avoided. Its use within a shell script is	    <SPANCLASS="emphasis"><ICLASS="EMPHASIS">not</I></SPAN> recommended.</P></TD></TR></TABLE></DIV></DD><DT><ANAME="WGETREF"></A><BCLASS="COMMAND">wget</B></DT><DD><P>The <BCLASS="COMMAND">wget</B> utility	      <ICLASS="FIRSTTERM">noninteractively</I> retrieves or	      downloads files from a Web or ftp site. It works well in a	      script.</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;wget -p http://www.xyz23.com/file01.html   2&nbsp;#  The -p or --page-requisite option causes wget to fetch all files   3&nbsp;#+ required to display the specified page.   4&nbsp;   5&nbsp;wget -r ftp://ftp.xyz24.net/~bozo/project_files/ -O $SAVEFILE   6&nbsp;#  The -r option recursively follows and retrieves all links   7&nbsp;#+ on the specified site.   8&nbsp;   9&nbsp;wget -c ftp://ftp.xyz25.net/bozofiles/filename.tar.bz2  10&nbsp;#  The -c option lets wget resume an interrupted download.  11&nbsp;#  This works with ftp servers and many HTTP sites.</PRE></TD></TR></TABLE></P><DIVCLASS="EXAMPLE"><HR><ANAME="QUOTEFETCH"></A><P><B>Example 15-41. Getting a stock quote</B></P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;#!/bin/bash   2&nbsp;# quote-fetch.sh: Download a stock quote.   3&nbsp;   4&nbsp;   5&nbsp;E_NOPARAMS=66   6&nbsp;   7&nbsp;if [ -z "$1" ]  # Must specify a stock (symbol) to fetch.   8&nbsp;  then echo "Usage: `basename $0` stock-symbol"   9&nbsp;  exit $E_NOPARAMS  10&nbsp;fi  11&nbsp;  12&nbsp;stock_symbol=$1  13&nbsp;  14&nbsp;file_suffix=.html  15&nbsp;# Fetches an HTML file, so name it appropriately.  16&nbsp;URL='http://finance.yahoo.com/q?s='  17&nbsp;# Yahoo finance board, with stock query suffix.  18&nbsp;  19&nbsp;# -----------------------------------------------------------  20&nbsp;wget -O ${stock_symbol}${file_suffix} "${URL}${stock_symbol}"  21&nbsp;# -----------------------------------------------------------  22&nbsp;  23&nbsp;  24&nbsp;# To look up stuff on http://search.yahoo.com:  25&nbsp;# -----------------------------------------------------------  26&nbsp;# URL="http://search.yahoo.com/search?fr=ush-news&#38;p=${query}"  27&nbsp;# wget -O "$savefilename" "${URL}"  28&nbsp;# -----------------------------------------------------------  29&nbsp;# Saves a list of relevant URLs.  30&nbsp;  31&nbsp;exit $?  32&nbsp;  33&nbsp;# Exercises:  34&nbsp;# ---------  35&nbsp;#  36&nbsp;# 1) Add a test to ensure the user running the script is on-line.  37&nbsp;#    (Hint: parse the output of 'ps -ax' for "ppp" or "connect."  38&nbsp;#  39&nbsp;# 2) Modify this script to fetch the local weather report,  40&nbsp;#+   taking the user's zip code as an argument.</PRE></TD></TR></TABLE><HR></DIV><P>See also <AHREF="contributed-scripts.html#WGETTER2">Example A-32</A> and <AHREF="contributed-scripts.html#BASHPODDER">Example A-33</A>.</P></DD><DT><ANAME="LYNXREF"></A><BCLASS="COMMAND">lynx</B></DT><DD><P>The <BCLASS="COMMAND">lynx</B> Web and file browser	      can be used inside a script (with the	      <TTCLASS="OPTION">-dump</TT> option) to retrieve a file from a Web or 	      ftp site noninteractively.</P><P>	   <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;lynx -dump http://www.xyz23.com/file01.html &#62;$SAVEFILE</PRE></TD></TR></TABLE>            </P><P>With the <TTCLASS="OPTION">-traversal</TT> option,	      <BCLASS="COMMAND">lynx</B> starts at the HTTP URL specified	      as an argument, then <SPANCLASS="QUOTE">"crawls"</SPAN> through all	      links located on that particular server. Used together	      with the <TTCLASS="OPTION">-crawl</TT> option, outputs page text	      to a log file.</P></DD><DT><ANAME="RLOGINREF"></A><BCLASS="COMMAND">rlogin</B></DT><DD><P><TTCLASS="REPLACEABLE"><I>Remote login</I></TT>, initates a	      session on a remote host. This command has security issues,	      so use <AHREF="communications.html#SSHREF">ssh</A> instead.</P></DD><DT><ANAME="RSHREF"></A><BCLASS="COMMAND">rsh</B></DT><DD><P><TTCLASS="REPLACEABLE"><I>Remote shell</I></TT>, executes	      command(s) on a remote host. This has security issues,	      so use <BCLASS="COMMAND">ssh</B> instead.</P></DD><DT><ANAME="RCPREF"></A><BCLASS="COMMAND">rcp</B></DT><DD><P><TTCLASS="REPLACEABLE"><I>Remote copy</I></TT>, copies files	      between two different networked machines.</P></DD><DT><ANAME="RSYNCREF"></A><BCLASS="COMMAND">rsync</B></DT><DD><P><TTCLASS="REPLACEABLE"><I>Remote synchronize</I></TT>, updates	    (synchronizes) files	      between two different networked machines.</P><P>	      <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>rsync -a ~/sourcedir/*txt /node1/subdirectory/</B></TT> 	      </PRE></TD></TR></TABLE>	    </P><DIVCLASS="EXAMPLE"><HR><ANAME="FC4UPD"></A><P><B>Example 15-42. Updating FC4</B></P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;#!/bin/bash   2&nbsp;# fc4upd.sh   3&nbsp;   4&nbsp;# Script author: Frank Wang.   5&nbsp;# Slight stylistic modifications by ABS Guide author.   6&nbsp;# Used in ABS Guide with permission.   7&nbsp;   8&nbsp;   9&nbsp;#  Download Fedora Core 4 update from mirror site using rsync.   10&nbsp;#  Should also work for newer Fedora Cores -- 5, 6, . . .  11&nbsp;#  Only download latest package if multiple versions exist,  12&nbsp;#+ to save space.  13&nbsp;  14&nbsp;URL=rsync://distro.ibiblio.org/fedora-linux-core/updates/  15&nbsp;# URL=rsync://ftp.kddilabs.jp/fedora/core/updates/  16&nbsp;# URL=rsync://rsync.planetmirror.com/fedora-linux-core/updates/  17&nbsp;  18&nbsp;DEST=${1:-/var/www/html/fedora/updates/}  19&nbsp;LOG=/tmp/repo-update-$(/bin/date +%Y-%m-%d).txt  20&nbsp;PID_FILE=/var/run/${0##*/}.pid  21&nbsp;  22&nbsp;E_RETURN=65        # Something unexpected happened.  23&nbsp;  24&nbsp;  25&nbsp;# General rsync options  26&nbsp;# -r: recursive download

⌨️ 快捷键说明

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