polysh入门

polysh主页:连接地址

安装

安装前提python版本>2.4 安装方法:pip install polysh

使用

说明

在使用polysh连接远程shell后,

  1. 命令前面的:表示,所有的命令都是在与polysh交互,并且命令不会发送到远程shell
  2. 在命令前的!表示在本地shell中执行,不会发送到远程shell

常用方法

  1. 主机名登录:polysh 'hostname-preffix-<number01-nunmber05>'
  2. polysh帮助:连接远程主机后,输入:help
ready (15)> :help
:add               添加远程连接Add one or many remote shells.
:chdir             改变本地工作目录(不是远程目录)Change the current directory of polysh (not the remote shells).
:disable           关闭发送命令到远程shell功能Disable sending commands to remote shells.
:enable            启用发送命令到远程shell功能Enable sending commands to remote shells.
:export_vars       在远程shell定义环境变量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              列出远程shell和对应的状态List remote shells and their states.
:purge             删除失效远程shell Delete disabled remote shells.
:quit              登出polysh Quit polysh.
:reconnect         重新连接已断开连接的远程shell 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.
  1. 推出polysh:连接远程主机后:quit

polysh交互命令详解

说明:一下所有都是在已进入polysh

一下所有交互注意命令前面的符号::表示与polysh交互;!表示与本地shell交互

add

例子::add hostname 将hostname shell添加到polysh批量处理的shell集合

chdir

例子::chdir testdir 将本地工作目录变更到原工作目录下的子文件夹testdir。

可以在测试前后使用!pwd查看本地工作目录,并对比。 我的在使用:chdir!pwd输出/opt/home/heguangfu/:chdir test后输出/opt/home/heguangfu/test

disable和enable

例子1::disable使所有的连接不处于激活状态,发送命令不会发送到远程shell。polysh交互提示由ready (15)>变为ready (0)>

此处使用:enable重新启用所有远程连接。

例子2::disable hostname使指定远程shell失效。

此处使用:enable hostname重新启用指定远程shell的连接。

例子3::enable worker16只启用worker16远程shell,其余的不启用。可实现对该shell单独操作

此处使用:enable重新启用所有远程连接。

list

例子::list列出所有连接和状态。

ready (14)> :list
worker16 disabled idle: colors=/home/heguangfu/.dircolors
worker17 enabled  idle: colors=/home/heguangfu/.dircolors
worker18 enabled  idle: colors=/home/heguangfu/.dircolors
worker19 enabled  idle: colors=/home/heguangfu/.dircolors
worker20 enabled  idle: colors=/home/heguangfu/.dircolors

之前使用:disable的远程shell状态为disable状态(worker16),其余为enable状态。

purge

例子:purge,删除出狱disable状态的远程shell。

worker17 enabled  idle: colors=/home/heguangfu/.dircolors
worker18 enabled  idle: colors=/home/heguangfu/.dircolors
worker19 enabled  idle: colors=/home/heguangfu/.dircolors
worker20 enabled  idle: colors=/home/heguangfu/.dircolors

没有worker16的连接和状态信息了。

如果在disable后,执行purge,那么就不能使用enable回复之前的连接了。

rename

例子1::rename XXX 将所有:list可以查看到的远程shell改名为XXX(原来是个主机hostname)。 改名后第一个为XXX,第二个为XXX#1,第10个为XXX#10。。。以此类推

例子2::rename AAA XXX, 将所有shell改名为AAA XXX+编号。

使用这种方式改名不知道怎么使用改变后的shell名来执行操作。。。求有知道的大神指教!

改名后,所有polysh交互命令均需要使用改名后的名字操作,例如想将原名字为worker16,现名为XXX的shell disable,必须使用现有名去操作。

replicate

例子::replicate worker16:filename。将worker16上的文件filename发送到所有其它enable的远程shell。

:replicate只能将文件从一个远程shell发送到其余远程shell。

set_log

将命令窗口输出到指定本地文件 例子::set_log /tmp/log,将远程shell输出到本地指定文件中。

set_debug

开启和关闭远程shell的调试。

例子::set_debug y,开启调试。 调试输出:

dx:aaa#11 : /home/xxx
[dbg] dx:aaa#11[running]: state => idle
[dbg] dx:aaa#12[running]: ==> /home/xxx\npolysh-4wBrH:prompt:YcWrA:13/\n

例子::set_debug n, 关闭调试。

转载于:https://my.oschina.net/hgfdoing/blog/704000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值