p-run is a utility that runs a program, script, or series of commands on a large number of hosts in parallel. It simplifies management of machines in computer labs. It uses ssh, and supports password and key-based authentication.
p-run uses libexpect, and will run in parallel across as many processes as specified. When run on a large number of hosts, its parallel nature significantly speeds up administration.
Downloading and compiling
- p-run requires libexpect
- Download p-run. It can be found here
- Uncompress: 'tar xjf p-run-tar.bz2'
- Type 'make'
p-run Usage
Usage: p-run <arguments> [-user <username>] - use this user to log in [-host <hostname>] - add <hostname> to the list of hosts [-hosts <filename>] - add hosts from <filename> to the list of hosts [-cmd <command>] - add <command> to the list of commands [-script <filename>] - add commands from <filename> [-threads #] - execute in # threads [-nopass] - turn off password prompt [-timeout #] - total time p-run is allowed to run (in seconds) [-version] - print version information
Example
p-run -hosts lists/test -cmd "hostname" -user root -threads 3 3 hosts, 1 commands, 3 threads Enter password: *** - apple - *** Last login: Mon Mar 31 12:10:39 2003 from asterix.cs.byu.edu [root@apple root]# hostname apple [root@apple root]# *** - pear - *** Last login: Mon Mar 31 12:11:27 2003 from asterix.cs.byu.edu [root@pear root]# hostname pear [root@pear root]# *** - hockey - *** Last login: Mon Mar 31 12:11:27 2003 from asterix.cs.byu.edu [root@hockey root]# hostname hockey [root@hockey root]# Total Time: 00:00:01.51, clock time: 00:00:00.53, savings: 00:00:00.98, speedup: 2.84
ToDo
Among the things I'd like to do (or have done) with p-run:
- Better handling of invalid password detection. Right now, you're likely to get 40 processes asking for a password.
- An option to quiet the output, or dump output to another file.
- An option for a gui and/or tui. It would be nice to display the number of machines (or a list of machines) currently in process, along with statistics, etc.
License
p-run is released under the GNU General Public License, Version 2, June 1991.