python - Fabric executing command on remote server doesn't work -


I want to use cloth in Python so that commands can be executed on remote server.

I have written:

fabric.api import * to import fabric.task import import from def do_some_thing (): run ("ls -lh") if __name__ == '__main__': execute (do_some_thing, host = ['

but it does not work and logs me ..

This output is:

< Pre> ➜ ~ python test.py [root@10.18.103.102] Execute 'do_some_thing' [root@10.18.103.102] Run: ls -lh [root@10.18.103.102] Out: root @ svn: ~ # [Root @ 10.18.103.102] Out: Using Root @ svn: ~ #

Import the fabric.contrib.files from * Importing fabric.api from env variable -

< Def myserver (): env.hosts = ['10 .18.103.102 '] Env.user =' root '# If you have key-based authentication, point to uniquut and private key # env.key_filename =' ~ / .ssh / Id_rsa '# If you have a password-based authentication, env.password =' ​​thaapAsword 'def ls (): Play (' LS-L ')

Now call them in a file call Save fabfile.py and execute (on the same directory) -

  $ fab myserver ls  

Perform both functions of the fabric After the second. Therefore, when it executes ls () , then there will be a description of the server in env .


Comments