lance bermudez
March 30th, 2015, 03:22 AM
my code is
#! /bin/python3.3
import subprocess
log_file = open ('command.log', 'a')
p = subprocess.Popen ('rsync -vaPhz --stats /home/lance/bin/ -e "ssh -p 22" 192.168.2.5:/home/lance/bin/python/bin', stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
print(p)
for line in iter (p.stderr.readline, ''):
log_file.write ('>ERROR:' + line)
for line in iter (p.stdout.readline, ''):
log_file.write (line)
log_file.close ()
error i get is
$ python test1.py
<subprocess.Popen object at 0x7fbd1a079d50>
What I'm trying to do is have the output print to screen and save to log file. I need some kind of output so that I know the script is working and not stuck.
#! /bin/python3.3
import subprocess
log_file = open ('command.log', 'a')
p = subprocess.Popen ('rsync -vaPhz --stats /home/lance/bin/ -e "ssh -p 22" 192.168.2.5:/home/lance/bin/python/bin', stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
print(p)
for line in iter (p.stderr.readline, ''):
log_file.write ('>ERROR:' + line)
for line in iter (p.stdout.readline, ''):
log_file.write (line)
log_file.close ()
error i get is
$ python test1.py
<subprocess.Popen object at 0x7fbd1a079d50>
What I'm trying to do is have the output print to screen and save to log file. I need some kind of output so that I know the script is working and not stuck.