0228-0228.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 135 行
HTML
135 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Filesystems, Disks, and Other Devices</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=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=11 //-->
<!-- PAGES=0195-0228 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0225-0227.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch12/0229-0232.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-228"><P>Page 228</P></A>
<P>The /dev/vcs* files provide a snapshot of what is in view on the corresponding VC. This
contains no newlines because there are none actually on the screen; a newline character just
moves the cursor after all. To make the captured data into the kind of thing you usually see in
text files or send to printers, you need to add newlines in the appropriate places. This can be
done with dd:
</P>
<!-- CODE SNIP //-->
<PRE>
$ dd cbs=80 conv=unblock </dev/vcs1 | lpr
</PRE>
<!-- END CODE SNIP //-->
<P>This command works only if the screen is 80 columns wide. This is not always true; the
kernel can set up a different video mode at boot time, and the
SVGATextMode command can be used to change it at any time.
</P>
<P>This problem can be overcome by using the other set of
devices, /dev/vcsa*. Reading from these devices gives a header, followed by the screen data with attribute bytes. The header
consists of two bytes indicating the screen size (height first), followed by two bytes indicating
the cursor position. The screen data is provided two bytes per character cell, the first
containing the attribute byte and the second containing the character data (as with
/dev/vcs*). This can be used to provide full-color screen dumps and so on. The following script uses
/dev/vcsa1 to determine the width of the VC and to get the conversion of
/dev/vcs1 right:
</P>
<!-- CODE //-->
<PRE>
#! /bin/sh
# Insist on exactly one argument (the VC number to dump)
[ $# -eq 1 ] || { echo "usage: $0 [vc-number]" >&2; exit 1 }
vc=$1 # Which VC to dump.
# Extract the VC's width from the second byte of the vcsa device.
# Th "unpack" expression extracts the value of the second
# character of the input (the vcsa device).
width=`perl -e `print unpack("x%C",<>);' < /dev/vcsa${vc}`
# Use dd(1) to convert the output now that we know the width.
dd cbs=${width} conv=unblock </dev/vcs${vc}
</PRE>
<!-- END CODE //-->
<H3><A NAME="ch11_ 39">
Summary
</A></H3>
<P>This chapter introduces the topics of character and block devices and filesystem
administration, with an overview of the hardware accessed via the special files in the directory
/dev. Further information can be obtained from the Linux Documentation Project material at
<a href="http://sunsite.unc.edu/ldp.">http://sunsite.unc.edu/LDP.</A> Much of the LDP material is also provided on the CD-ROM
accompaning this book.
</P>
<P><CENTER>
<a href="0225-0227.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch12/0229-0232.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?