Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
James Joseph
4,885 PointsPython: import subprocess [SOLVED]
Hey guys, I've just finished the first two parts of beginner to python and I thought I'd challenge myself by doing a simple script before starting to make the first app tutorial. I'm doing an rsync script and I'm trying to run the rsync command.
I've looked into it and saw about the subprocess.call command but I just want to confirm if this is correct?
elif startbk == 1:
print("Starting backup, rsync -avv {} {} --log-file={}".format(sor,des,logloc))
import subprocess
subprocess.call(['rsync', '-avv', sor des '--log-file=' logloc])
Any assistance or input on this is greatly appreciated.
James Joseph
4,885 PointsJames Joseph
4,885 PointsI looked into it a bit further and I figured out how to do it, I've redesigned my script but my issue with doing the subprocess call was that it doesn't seem to take variables like that in a call. You have to make the variable first with the commands and then call the variable.
My solution: