This is the 12th day of my participation in Gwen Challenge

Batchcmd Perform batch operations on Linux hosts

Support continuous interaction on multiple host operation Shell, password and private key mode support file upload and download, the overall implementation of common batch operations, lightweight Ansible. For the continuous output command, such as the top command, you need to specify the output times by -c. Otherwise, the output will continue indefinitely. Like to remember to follow oh.

Github

BatchCmd source welcome star~

Runtime environment

Python3.0 + is required, and pyinstaller is required to run in binary

The installation

  1. Clone to the local PC, modify the. CFG configuration file in the root directory, and run batchcmd. py
  2. Clone to the local PC, install PyInstaller, and run the pyInstaller -f batchcmd. py command to generate a binary file and place it in the same directory as the. CFG configuration file

The configuration file

The password and key can be used

  1. Password format: 172.16.3.131 -P Password
  2. Private key mode: 172.16.3.131-key Absolute path of the private key
  3. The default user name is root. The new user name is 172.16.3.131. -u tyy -p Password
  4. SSH port 22 is used. There is no configuration at present and the source code needs to be modified.

Start the command

The command instructions
-h help
-i Enable continuous interaction
-g Specify the name of the host group for the configuration file
-c Shell command (top and other continuous output commands, please add the output times, otherwise it will not be displayed)
-fun Currently, put and GET can be used for SFTP upload and download respectively
-form Used with fun’s PUT or get to specify the original file directory
-to Used with fun’s PUT or get to specify the destination file directory
Enter CC in the interaction Equivalent to CTRL + C

Source code mode:

python3 bashCMD.py  -g web -i -c 'ls'
python3 bashCMD.py -g web -fun put -form /home/123.txt -to /home/123.txt
python3 bashCMD.py -g web -fun get -form /home/123.txt -to /home/123.txt
Copy the code

Binary mode:

./bashCMD -g web -i -c 'ls'
./bashCMD -g web -fun put -form /home/123.txt -to /home/123.txt
./bashCMD -g web -fun get -form /home/123.txt -to /home/123.txt
Copy the code