Work needs, often use Xshell to connect remote Linux machines, view some of the above document information, and then constantly switch directories, cd.....cd ..., heart tired.
Why not use the script to implement it. Go online to read some information, there is a solution, thank you for sharing the results of the IT people, here to share my experience it.
1, the installation of related support library:
Install Pycrypto:http://www.voidspace.org.uk/python/modules.shtml#pycrypto
Install paramiko,https://pypi.python.org/pypi/paramiko/1.7.7.1
Extract to C disk, cmd switch to the corresponding directory execution: Python setup.py build, then execute Python setup.py install
2, Paramiko use:
def get_search_text (self):
# SSH Remote Connection
SSH = Paramiko. Sshclient ()
Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ())
Ssh.connect (HOST_IP, host_port, username, password)
# orders to be executed
Swithch_path = "CD docker/conf/"
search_contents = "grep ' Game ' Config.xml"
# Note: When you execute multiple commands sequentially, separate the commands with semicolons
Command = swithch_path+ ";" +search_contents
# Execute Command
stdin, stdout, stderr = ssh.exec_command (command)
Err = Stderr.readlines ()
out = Stdout.readlines ()
If Len (err)!= 0:
Print "==execute command[", Command, "] failed:", err
Else
Print "==execute command[", Command, "] success:", out
Ssh.close ()
Return out
3, the definition of this method, directly with robot to call the good, and then directly run the case of robot, you can get to the Dongdong.