| 1 |
This directory contains scripts that give examples of using Pexpect. |
| 2 |
|
| 3 |
hive.py |
| 4 |
This script creates SSH connections to a list of hosts that |
| 5 |
you provide. Then you are given a command line prompt. Each |
| 6 |
shell command that you enter is sent to all the hosts. The |
| 7 |
response from each host is collected and printed. For example, |
| 8 |
you could connect to a dozen different machines and reboot |
| 9 |
them all at once. |
| 10 |
|
| 11 |
script.py |
| 12 |
This implements a command similar to the classic BSD "script" command. |
| 13 |
This will start a subshell and log all input and output to a file. |
| 14 |
This demonstrates the interact() method of Pexpect. |
| 15 |
|
| 16 |
fix_cvs_files.py |
| 17 |
This is for cleaning up binary files improperly added to |
| 18 |
CVS. This script scans the given path to find binary files; |
| 19 |
checks with CVS to see if the sticky options are set to -kb; |
| 20 |
finally if sticky options are not -kb then uses 'cvs admin' |
| 21 |
to set the -kb option. |
| 22 |
|
| 23 |
ftp.py |
| 24 |
This demonstrates an FTP "bookmark". |
| 25 |
This connects to an ftp site; does a few ftp commands; and then gives the user |
| 26 |
interactive control over the session. In this case the "bookmark" is to a |
| 27 |
directory on the OpenBSD ftp server. It puts you in the i386 packages |
| 28 |
directory. You can easily modify this for other sites. |
| 29 |
This demonstrates the interact() method of Pexpect. |
| 30 |
|
| 31 |
monitor.py |
| 32 |
This runs a sequence of system status commands on a remote host using SSH. |
| 33 |
It runs a simple system checks such as uptime and free to monitor |
| 34 |
the state of the remote host. |
| 35 |
|
| 36 |
passmass.py |
| 37 |
This will login to a list of hosts and change the password of the |
| 38 |
given user. This demonstrates scripting logins; although, you could |
| 39 |
more easily do this using the pxssh subclass of Pexpect. |
| 40 |
See also the "hive.py" example script for a more general example |
| 41 |
of scripting a collection of servers. |
| 42 |
|
| 43 |
python.py |
| 44 |
This starts the python interpreter and prints the greeting message backwards. |
| 45 |
It then gives the user interactive control of Python. It's pretty useless! |
| 46 |
|
| 47 |
rippy.py |
| 48 |
This is a wizard for mencoder. It greatly simplifies the process of |
| 49 |
ripping a DVD to mpeg4 format (XviD, DivX). It can transcode from any |
| 50 |
video file to another. It has options for resampling the audio stream; |
| 51 |
removing interlace artifacts, fitting to a target file size, etc. |
| 52 |
There are lots of options, but the process is simple and easy to use. |
| 53 |
|
| 54 |
ssh_tunnel.py |
| 55 |
This starts an SSH tunnel to a remote machine. It monitors the connection |
| 56 |
and restarts the tunnel if it goes down. |
| 57 |
|
| 58 |
uptime.py |
| 59 |
This will run the uptime command and parse the output into python variables. |
| 60 |
This demonstrates using a single regular expression to match the output |
| 61 |
of a command and capturing different variable in match groups. |
| 62 |
The regular expression takes into account a wide variety of different |
| 63 |
formats for uptime output. |
| 64 |
|
| 65 |
df.py |
| 66 |
This collects filesystem capacity info using the 'df' command. |
| 67 |
Tuples of filesystem name and percentage are stored in a list. |
| 68 |
A simple report is printed. Filesystems over 95% capacity are highlighted. |
| 69 |
|
| 70 |
PEXPECT LICENSE |
| 71 |
|
| 72 |
This license is approved by the OSI and FSF as GPL-compatible. |
| 73 |
http://opensource.org/licenses/isc-license.txt |
| 74 |
|
| 75 |
Copyright (c) 2012, Noah Spurrier <[email protected]> |
| 76 |
PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY |
| 77 |
PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE |
| 78 |
COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. |
| 79 |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 80 |
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 81 |
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 82 |
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 83 |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 84 |
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 85 |
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 86 |
|