📄 communications.html
字号:
WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>ping localhost</B></TT> <TTCLASS="COMPUTEROUTPUT">PING localhost.localdomain (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. 64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=0 ttl=255 time=709 usec 64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=255 time=286 usec --- localhost.localdomain ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/mdev = 0.286/0.497/0.709/0.212 ms</TT> </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="EMPHASIS">whois</I> server to query. See <AHREF="othertypesv.html#EX18">Example 4-6</A> and <AHREF="communications.html#SPAMLOOKUP">Example 12-36</A>.</P></DD><DT><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="AEN9739"HREF="#FTN.AEN9739">[1]</A> </P></DD><DT><BCLASS="COMMAND">chfn</B></DT><DD><P>Change information disclosed by the <BCLASS="COMMAND">finger</B> command.</P></DD><DT><BCLASS="COMMAND">vrfy</B></DT><DD><P>Verify an Internet e-mail address.</P></DD></DL></DIV><DIVCLASS="VARIABLELIST"><P><B><ANAME="COMMREMOTE1"></A>Remote Host Access</B></P><DL><DT><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="EMPHASIS">xmodem</I> protocol. These are generally part of a communications package, such as <BCLASS="COMMAND">minicom</B>.</P></DD><DT><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="EMPHASIS">zmodem</I> protocol. <ICLASS="EMPHASIS">Zmodem</I> has certain advantages over <ICLASS="EMPHASIS">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 17-6</A>, <AHREF="contributed-scripts.html#ENCRYPTEDPW">Example A-4</A>, and <AHREF="contributed-scripts.html#FTPGET">Example A-13</A>).</P></DD><DT><BCLASS="COMMAND">uucp</B>, <BCLASS="COMMAND">uux</B>, <BCLASS="COMMAND">cu</B></DT><DD><P><BCLASS="COMMAND">uucp</B>: <ICLASS="EMPHASIS">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="EMPHASIS">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>: <ICLASS="EMPHASIS">C</I>all <ICLASS="EMPHASIS">U</I>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 telnet protocol contains security holes and should therefore probably be avoided.</P></TD></TR></TABLE></DIV></DD><DT><ANAME="WGETREF"></A><BCLASS="COMMAND">wget</B></DT><DD><P>The <BCLASS="COMMAND">wget</B> utility <ICLASS="EMPHASIS">non-interactively</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 wget -p http://www.xyz23.com/file01.html 2 # The -p or --page-requisite option causes wget to fetch all files 3 #+ required to display the specified page. 4 5 wget -r ftp://ftp.xyz24.net/~bozo/project_files/ -O $SAVEFILE 6 # The -r option recursively follows and retrieves all links 7 #+ on the specified site.</PRE></TD></TR></TABLE></P><DIVCLASS="EXAMPLE"><HR><ANAME="QUOTEFETCH"></A><P><B>Example 12-38. Getting a stock quote</B></P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> 1 #!/bin/bash 2 # quote-fetch.sh: Download a stock quote. 3 4 5 E_NOPARAMS=66 6 7 if [ -z "$1" ] # Must specify a stock (symbol) to fetch. 8 then echo "Usage: `basename $0` stock-symbol" 9 exit $E_NOPARAMS 10 fi 11 12 stock_symbol=$1 13 14 file_suffix=.html 15 # Fetches an HTML file, so name it appropriately. 16 URL='http://finance.yahoo.com/q?s=' 17 # Yahoo finance board, with stock query suffix. 18 19 # ----------------------------------------------------------- 20 wget -O ${stock_symbol}${file_suffix} "${URL}${stock_symbol}" 21 # ----------------------------------------------------------- 22 23 24 # To look up stuff on http://search.yahoo.com: 25 # ----------------------------------------------------------- 26 # URL="http://search.yahoo.com/search?fr=ush-news&p=${query}" 27 # wget -O "$savefilename" "${URL}" 28 # ----------------------------------------------------------- 29 # Saves a list of relevant URLs. 30 31 exit $? 32 33 # Exercises: 34 # --------- 35 # 36 # 1) Add a test to ensure the user running the script is on-line. 37 # (Hint: parse the output of 'ps -ax' for "ppp" or "connect." 38 # 39 # 2) Modify this script to fetch the local weather report, 40 #+ 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-29</A> and <AHREF="contributed-scripts.html#BASHPODDER">Example A-30</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 non-interactively. <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> 1 lynx -dump http://www.xyz23.com/file01.html >$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><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><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><BCLASS="COMMAND">rcp</B></DT><DD><P><TTCLASS="REPLACEABLE"><I>Remote copy</I></TT>, copies files between two different networked machines.</P></DD><DT><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 12-39. Updating FC4</B></P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> 1 #!/bin/bash 2 # fc4upd.sh 3 4 # Script author: Frank Wang. 5 # Slight stylistic modifications by ABS Guide author. 6 # Used in ABS Guide with permission. 7 8 9 # Download Fedora 4 update from mirror site using rsync. 10 # Only download latest package if multiple versions exist, 11 #+ to save space. 12 13 URL=rsync://distro.ibiblio.org/fedora-linux-core/updates/ 14 # URL=rsync://ftp.kddilabs.jp/fedora/core/updates/ 15 # URL=rsync://rsync.planetmirror.com/fedora-linux-core/updates/ 16 17 DEST=${1:-/var/www/html/fedora/updates/} 18 LOG=/tmp/repo-update-$(/bin/date +%Y-%m-%d).txt 19 PID_FILE=/var/run/${0##*/}.pid 20 21 E_RETURN=65 # Something unexpected happened. 22 23 24 # General rsync options 25 # -r: recursive download 26 # -t: reserve time 27 # -v: verbose 28
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -