diff options
author | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2007-12-27 02:40:52 +0000 |
---|---|---|
committer | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2007-12-27 02:40:52 +0000 |
commit | d894fb5ca40463900ec174ad66ae43f0e3d78a49 (patch) | |
tree | 95e101362db44a18ebbd8ac95c656fa2ff0591a7 | |
parent | d88cd56a6a5848ab016fb4ab09acb0efcaf35b30 (diff) | |
download | pexpect-d894fb5ca40463900ec174ad66ae43f0e3d78a49.tar.gz |
Added documentation for logfiles.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@507 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r-- | pexpect/doc/examples.html | 22 | ||||
-rw-r--r-- | pexpect/pexpect.py | 12 | ||||
-rwxr-xr-x | pexpect/tools/websync.py | 8 |
3 files changed, 34 insertions, 8 deletions
diff --git a/pexpect/doc/examples.html b/pexpect/doc/examples.html index c4f0943..2884a5c 100644 --- a/pexpect/doc/examples.html +++ b/pexpect/doc/examples.html @@ -6,15 +6,25 @@ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Author" content="Noah Spurrier"> <meta name="Keywords" - content="pexpect, Noah Spurrier, pypect, Python, Libes, TCL, Expect, pipe, popen, pyExpect, expectpy, expect-like, expect-alike, expect like"> -<meta name="Description" - content="Examples for using Pexpect."> + content="pexpect, Noah Spurrier, Python, Libes, TCL, Expect, pipe, popen, pyExpect, expectpy, expect-like, expect-alike, expect like"> +<meta name="Description" content="Examples for using Pexpect."> </head> <body bgcolor="#ffffff" text="#000000"> <div id="Header"> <h1>Pexpect Examples</h1> </div> <div id="Content"> + +<p><span class="code">hive.py</span></p> +<p><blockquote> +This script creates SSH connections to a list of hosts that +you provide. Then you are given a command line prompt. Each +shell command that you enter is sent to all the hosts. The +response from each host is collected and printed. For example, +you could connect to a dozen different machines and reboot +them all at once. +</p></blockquote> + <p><span class="code">script.py</span></p> <p><blockquote> This implements a command similar to the classic BSD @@ -111,11 +121,15 @@ match groups. The grouping regular expression handles a wide variety of different uptime formats. </blockquote> + <p> <a href="http://sourceforge.net/projects/pexpect/" title="The Pexpect project page on SourceForge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=59762&type=5" alt="The Pexpect project page on SourceForge.net" border="0" - height="31" width="105"> </a> </div> + height="31" width="105"> </a> +</p> +</div> + </body> </html> diff --git a/pexpect/pexpect.py b/pexpect/pexpect.py index f6bb12a..6d23d8e 100644 --- a/pexpect/pexpect.py +++ b/pexpect/pexpect.py @@ -332,6 +332,18 @@ class spawn (object): child = pexpect.spawn('some_command') child.logfile = sys.stdout + The logfile_read and logfile_send members can be used to separately log + the input from the child and output sent to the child. Sometimes you + don't want to see everything you write to the child. You only want to + log what the child sends back. For example:: + + child = pexpect.spawn('some_command') + child.logfile_read = sys.stdout + + To separately log output sent to the child use logfile_send:: + + self.logfile_send = fout + The delaybeforesend helps overcome a weird behavior that many users were experiencing. The typical problem was that a user would expect() a "Password:" prompt and then immediately call sendline() to send the diff --git a/pexpect/tools/websync.py b/pexpect/tools/websync.py index d1c6af4..e79bedc 100755 --- a/pexpect/tools/websync.py +++ b/pexpect/tools/websync.py @@ -14,28 +14,28 @@ X = getpass.getpass('Password: ') pp_pattern=["(?i)password:", "(?i)enter passphrase for key '.*?':"] p = pexpect.spawn ('scp -r doc/. noah@shell.sourceforge.net:/home/groups/p/pe/pexpect/htdocs/.') -p.logfile = sys.stdout +p.logfile_read = sys.stdout p.expect (pp_pattern) p.sendline (X) p.expect (pexpect.EOF) print p.before p = pexpect.spawn ('scp doc/clean.css doc/email.png noah@shell.sourceforge.net:/home/groups/p/pe/pexpect/htdocs/clean.css') -p.logfile = sys.stdout +p.logfile_read = sys.stdout p.expect (pp_pattern) p.sendline (X) p.expect (pexpect.EOF) print p.before #p = pexpect.spawn ('ssh noah@use-pr-shell1.sourceforge.net "cd htdocs;tar zxvf pexpect-doc.tgz"') -#p.logfile = sys.stdout +#p.logfile_read = sys.stdout #p.expect ('password:') #p.sendline (X) #p.expect (pexpect.EOF) #print p.before p = pexpect.spawn ('scp dist/pexpect-*.tar.gz noah@shell.sourceforge.net:/home/groups/p/pe/pexpect/htdocs/.') -p.logfile = sys.stdout +p.logfile_read = sys.stdout p.expect (pp_pattern) p.sendline (X) p.expect (pexpect.EOF) |