Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fabric import Connection
- from fabric import task
- ssh_conn = Connection(
- host="",
- user="",
- connect_kwargs = {'password': ''},
- )
- def list_folder():
- with ssh_conn.cd('/webapps'):
- res = ssh_conn.run('ls', hide=True)
- res2 = ssh_conn.run('ls -lisat {path}'.format(path=res.stdout), hide=True)
- print(res2.stdout)
- def get_file_path():
- with ssh_conn.cd('/tmp'):
- res = ssh_conn.run('readlink -f teste.txt', hide=True)
- return res.stdout
- def show_file_content():
- from io import BytesIO
- file_path = get_file_path()
- print(file_path)
- content = ssh_conn.run('cat ' + file_path, hide=True).stdout
- contents = content.split('\n')
- for c in contents:
- if not c:
- continue
- print(c)
- print(len(contents))
- @task
- def check(ctx):
- show_file_content()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement