polysh批量執行shell命令

來源:互聯網
上載者:User

標籤:python   border   files   

安裝polysh
wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gztar -zxvf polysh-0.4.tar.gzcd polysh-0.4sudo python setup.py install
使用polysh

Usage: /usr/bin/polysh [OPTIONS] HOSTS...

Control commands are prefixed by ":". Use :help for the list

Options:

  --version             show program‘s version number and exit

  -h, --help            show this help message and exit

  --hosts-file=FILE     read hostnames from given file, one per line

  --command=CMD         command to execute on the remote shells

  --ssh=SSH             ssh command to use [exec ssh -oLogLevel=Quiet -t

                        %(host)s exec bash --noprofile]

  --user=USER           remote user to log in as

  --no-color            disable colored hostnames [enabled]

  --password-file=FILE  read a password from the specified file. - is the tty.

  --log-file=LOG_FILE   file to log each machine conversation [none]

  --abort-errors        abort if some shell fails to initialize [ignore]

  --debug               print debugging information

 

建立一個host列表檔案host.list,每一行為一個hostname或IP:

localhost

localhost.localdomain

localhost4

localhost4.localdomain4

node0003.nemongo.com

執行:polysh --user=root --hosts-file=host.list,當全部串連OK的時候,會提示一個ready (5)> ,這裡的數字是host的個數。

650) this.width=650;" title="clipboard" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="clipboard" src="http://s3.51cto.com/wyfs02/M02/6C/CB/wKioL1VStWnyA7-xAAGNP9ZB7_E290.jpg" "795" height="146" />

注意:登入的之前如果不想輸入密碼,可以預先配置好SSH無密碼登入。

為了可以方便的使用shell指令碼自動批量運行命令,可以加上參數--command,指定需要執行的命令:

650) this.width=650;" title="clipboard[1]" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="clipboard[1]" src="http://s3.51cto.com/wyfs02/M00/6C/CB/wKioL1VStWuRKdn1AAFz65JlhsM946.jpg" "795" height="113" />

polysh批量執行shell命令

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.