官方主页的介绍如下:
Polysh is a tool to aggregate several remote shells into one. It is used to launch an interactive remote shell on many machines at once. It is written in Python and requires Python ≥ 2.4.
平时我们登录远程主机时,每登录一个远程主机均需要打开一个shell,然后在各个shell中与远程主机进行命令交互。Polysh的作用是允许你在一个shell中同时向多个远程主机发送命令,返回的结果在这个shell中显示。Polysh对于需要登录多个远程主机,并执行相同指令的情况,大大减少了我们的工作量。
通过下载源代码的试安装,步骤如下:
wget wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gz tar -zxvf polysh-0.4.tar.gz cd polysh-0.4 su python setup.py install
打开文件-属性,选择SSH选项,选择”使用密码处理的Xagent(SSH代理)”。然后将Xshell重启。
polysh 106.2.52.163 106.2.52.161
可以看到以下提示,说明同时登录上了两个远程主机
ready (2)>
执行命令
ready (2)> pwd
显示
106.2.52.163 : /home/lihao 106.2.52.161 : /home/lihao
说明pwd命令已经同时发往106.2.52.163,106.2.52.161,并得到其返回的结果。
以冒号开头的指令不会发送到远程主机,polysh会执行以冒号开头的指令,例如
ready (2)> :help :add Add one or many remote shells. :chdir Change the current directory of polysh (not the remote shells). :disable Disable sending commands to remote shells. :enable Enable sending commands to remote shells. :export_vars Export some environment variables on enabled remote shells. :help List control commands or show their documentations. :hide_password Do not echo the next typed line. :list List remote shells and their states. :purge Delete disabled remote shells. :quit Quit polysh. :reconnect Try to reconnect to disconnected remote shells. :rename Rename all enabled remote shells with the argument. :replicate Copy a path from one remote shell to all others :reset_prompt Change the prompt to be recognized by polysh. :send_ctrl Send a control character to remote shells. :set_debug Enable or disable debugging output for remote shells. :set_log Duplicate every console I/O into the given local file. :show_read_buffer Print the data read by remote shells. :upload Upload the specified local path to enabled remote shells.
具体指令可以参考上述的说明。
可以通过git获取polysh的源码
git clone git://repo.or.cz/polysh.git