標籤: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命令