📄 ch20_04.htm
字号:
<html><head><title>Unattended Execution (Programming Perl)</title><!-- STYLESHEET --><link rel="stylesheet" type="text/css" href="../style/style1.css"><!-- METADATA --><!--Dublin Core Metadata--><meta name="DC.Creator" content=""><meta name="DC.Date" content=""><meta name="DC.Format" content="text/xml" scheme="MIME"><meta name="DC.Generator" content="XSLT stylesheet, xt by James Clark"><meta name="DC.Identifier" content=""><meta name="DC.Language" content="en-US"><meta name="DC.Publisher" content="O'Reilly & Associates, Inc."><meta name="DC.Source" content="" scheme="ISBN"><meta name="DC.Subject.Keyword" content=""><meta name="DC.Title" content="Unattended Execution"><meta name="DC.Type" content="Text.Monograph"></head><body><!-- START OF BODY --><!-- TOP BANNER --><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home"><map name="banner-map"><AREA SHAPE="RECT" COORDS="0,0,466,71" HREF="index.htm" ALT="Programming Perl"><AREA SHAPE="RECT" COORDS="467,0,514,18" HREF="jobjects/fsearch.htm" ALT="Search this book"></map><!-- TOP NAV BAR --><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch20_03.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="ch20_01.htm">Chapter 20: The Perl Debugger</a></td><td align="right" valign="top" width="172"><a href="ch20_05.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr></table></div><hr width="515" align="left"><!-- SECTION BODY --><h2 class="sect1">20.4. Unattended Execution</h2><p><a name="INDEX-3637"></a><a name="INDEX-3638"></a>During startup, options are initialized from <tt class="literal">$ENV{PERLDB_OPTS}</tt>.You may place the initialization options <tt class="literal">TTY</tt>, <tt class="literal">noTTY</tt>,<tt class="literal">ReadLine</tt>, and <tt class="literal">NonStop</tt> there.</p><p>If your init file contains:<blockquote><pre class="programlisting">parse_options("NonStop=1 LineInfo=tperl.out AutoTrace");</pre></blockquote>then your program will run without human intervention, putting traceinformation into the file <em class="emphasis">db.out</em>. (If you interrupt it, you'dbetter reset <tt class="literal">LineInfo</tt> to <em class="emphasis">/dev/tty</em> if you expect to see anything.)</p><p>The following options can be specified only at startup. To set them inyour init file, call <tt class="literal">parse_options("</tt><em class="replaceable">OPT</em><tt class="literal">=</tt><em class="replaceable">VAL</em><tt class="literal">")</tt>.</p><dl><dt><b><tt class="literal">TTY</tt></b></dt><dd><p><a name="INDEX-3639"></a>The terminal to use for debugging I/O.</p></dd><dt><b><tt class="literal">noTTY</tt></b></dt><dd><p> If set, thedebugger goes into <tt class="literal">NonStop</tt> mode and will notconnect to a terminal. If interrupted (or if control goes to thedebugger via explicit setting of <tt class="literal">$DB::signal</tt> or<tt class="literal">$DB::single</tt> from the Perl program), it connects toa terminal specified in the <tt class="literal">TTY</tt> option at startup,or to a terminal found at run time using the<tt class="literal">Term::Rendezvous</tt> module of your choice.<a name="INDEX-3640"></a><a name="INDEX-3641"></a><a name="INDEX-3642"></a></p><p>This module should implement a method named <tt class="literal">new</tt>that returns an object with two methods: <tt class="literal">IN</tt> and<tt class="literal">OUT</tt>. These should return filehandles for thedebugger to use its input and output correspondingly. The<tt class="literal">new</tt> method should inspect an argument containingthe value of <tt class="literal">$ENV{PERLDB_NOTTY}</tt> at startup, or<tt class="literal">"/tmp/perldbtty$$"</tt> otherwise. This file is notinspected for proper ownership or wide-open write access, so securityhazards are theoretically possible.</p></dd><dt><b><tt class="literal">ReadLine</tt></b></dt><dd><p><a name="INDEX-3643"></a>If false, <tt class="literal">ReadLine</tt> support in the debugger isdisabled in order to debug applications that themselves use a<tt class="literal">ReadLine</tt> module.</p></dd><dt><b><tt class="literal">NonStop</tt></b></dt><dd><p><a name="INDEX-3644"></a>If set, the debugger goes into noninteractive mode until interrupted,or your program sets <tt class="literal">$DB::signal</tt> or<tt class="literal">$DB::single</tt>.</p></dd></dl><p>Options can sometimes be uniquely abbreviated by the first letter, butwe recommend that you always spell them out in full, forlegibility and future compatibility.</p><p><a name="INDEX-3645"></a>Here's an example of using the <tt class="literal">PERLDB_OPTS</tt> environment variableto set options automatically.<a href="#FOOTNOTE-1">[1]</a> It runs your programnoninteractively, printing information on each entry into asubroutine and for each line executed. Output from the debugger'strace are placed into the <em class="emphasis">tperl.out</em> file. This lets your programstill use its regular standard input and output, without the traceinformation getting in the way.<blockquote><pre class="programlisting">$ PERLDB_OPTS="NonStop frame=1 AutoTrace LineInfo=tperl.out" perl -d myprog</pre></blockquote>If you interrupt the program, you'll need to quickly reset to <tt class="literal">O LineInfo=/dev/tty</tt> or whatever makes sense on your platform.Otherwise, you won't see the debugger's prompting.</p><blockquote class="footnote"><a name="FOOTNOTE-1"></a><p>[1] We're using <em class="emphasis">sh</em>shell syntax to show environment variable settings. Users of othershells should adjust accordingly.</p></blockquote><!-- BOTTOM NAV BAR --><hr width="515" align="left"><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch20_03.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0"></a></td><td align="right" valign="top" width="172"><a href="ch20_05.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr><tr><td align="left" valign="top" width="172">20.3. Debugger Customization</td><td align="center" valign="top" width="171"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0"></a></td><td align="right" valign="top" width="172">20.5. Debugger Support</td></tr></table></div><hr width="515" align="left"><!-- LIBRARY NAV BAR --><img src="../gifs/smnavbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links"><p><font size="-1"><a href="copyrght.htm">Copyright © 2001</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"> <area shape="rect" coords="2,-1,79,99" href="../index.htm"><area shape="rect" coords="84,1,157,108" href="../perlnut/index.htm"><area shape="rect" coords="162,2,248,125" href="../prog/index.htm"><area shape="rect" coords="253,2,326,130" href="../advprog/index.htm"><area shape="rect" coords="332,1,407,112" href="../cookbook/index.htm"><area shape="rect" coords="414,2,523,103" href="../sysadmin/index.htm"></map><!-- END OF BODY --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -