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, 關閉調試。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章