polysh 同时处理多台服务器

Polysh介绍

官方主页的介绍如下:

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对于需要登录多个远程主机,并执行相同指令的情况,大大减少了我们的工作量。

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

Xshell配置Xagent

打开文件-属性,选择SSH选项,选择”使用密码处理的Xagent(SSH代理)”。然后将Xshell重启。

Polysh使用

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指令

以冒号开头的指令不会发送到远程主机,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.

具体指令可以参考上述的说明。

Polysh源码

可以通过git获取polysh的源码

git clone git://repo.or.cz/polysh.git

参考资料

  1. Polysh官方文档, http://guichaz.free.fr/polysh/
  2. 运维工具-Polysh 入门, http://segmentfault.com/a/1190000000492374

--------------------- 本文来自 haozlee 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/lihao21/article/details/48319085?utm_source=copy

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值