PDA

View Full Version : rsync and ssh inside of python 3.3.2



lance bermudez
February 14th, 2015, 06:30 AM
import os
os.system('''rsync -vaPhz /home/lance/bin/ -e \"ssh -p 9455\" 192.186.12.21:/home/lance/bin/''')

or
from subprocess import Popen, PIPE, STDOUT
shell_command = '''rsync -vaPhz /home/lance/bin/ -e \"ssh -p 9455\" 192.168.2.2:/home/lance/bin/'''
event = Popen(shell_command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
output = event.communicate()
print (output)

both work but do not show files.

It works but is their a way to show the files as they are being copied over? I'm new to python and just learned this tonight.

lance bermudez
March 5th, 2015, 12:27 AM
will let you see the output from rsync as the files are copied

import subprocess
subprocess.call(['rsync','-vaPhz','/home/lance/bin/','-e','ssh -p 9455','192.168.2.2:/home/lance/Downloads/bin/bin'])