Using Python Fabric without the command-line tool (fab)

后端 未结 5 1008
旧时难觅i
旧时难觅i 2021-02-01 06:19

Altough Fabric documentations refers to a way of using the library for SSH access without requiring the fab command-line tool and/or tasks, I can\'t seem to manage a way to do i

5条回答
  •  难免孤独
    2021-02-01 06:39

    #!/usr/bin/env python
    from fabric.api import hosts, run, task
    from fabric.tasks import execute
    
    @task
    @hosts(['user@host:port'])
    def test():
        run('hostname -f')
    
    if __name__ == '__main__':
       execute(test)
    

    More information: http://docs.fabfile.org/en/latest/usage/library.html

提交回复
热议问题