#coding:utf-8
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.colors import *
env.hosts = ['192.168.1.112']
env.user = 'root'
#env.passwords ={
#
#}
@task
def upload_file():
with settings(warn_only=True):
local('tar -czf abc.tar.gz abc.txt')
result = put('abc.tar.gz','/mnt/abc.tar.gz')
if result.failed :
abort('put abc.tar.gz failed')
with settings(warn_only=True):
local_file = local('md5sum abc.tar.gz',capture=True).split(' ')[0]
remote_file = run('md5sum /mnt/abc.tar.gz').split(' ')[0]
if local_file == remote_file:
print(green('local == remote'))
else:
print(red('local != remote'))
run('mkdir /mnt/test')
run('tar -zxf /mnt/abc.tar.gz -C /mnt/test')
fabric下載文件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.