Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.04; 'received:mail.rr.com': 0.07; 'skip:/ 10': 0.07; 'works.': 0.07; '-rf': 0.09; 'cmd': 0.09; 'option:': 0.09; 'received:10.127': 0.09; 'received:75.180': 0.09; 'received:75.180.132': 0.09; 'received:cdptpa-omtalb.mail.rr.com': 0.09; 'passing': 0.15; 'skip:p 40': 0.15; 'subprocess': 0.16; 'examples': 0.18; '>>>': 0.18; 'import': 0.21; 'expand': 0.26; 'older': 0.27; 'updating': 0.27; 'received:rr.com': 0.30; 'code': 0.31; 'could': 0.32; 'to:addr:python-list': 0.33; 'list': 0.35; 'same.': 0.35; 'something': 0.35; 'really': 0.36; 'but': 0.36; 'subject:with': 0.36; 'thank': 0.36; 'subject:: ': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'easy': 0.60; 'from:no real name:2**0': 0.60; 'skip:u 10': 0.60; 'containing': 0.61; 'first': 0.61; 'insight': 0.71; 'sharing': 0.74; 'quote,': 0.84; 'subject:Moving': 0.84; 'subject:content': 0.84; 'safer': 0.91 Authentication-Results: cdptpa-omtalb.mail.rr.com smtp.user=jyoung79@kc.rr.com; auth=pass (LOGIN) X-Authority-Analysis: v=2.0 cv=IuCcgcDg c=1 sm=0 a=05ChyHeVI94A:10 a=IkcTkHD0fZMA:10 a=ayC55rCoAAAA:8 a=AEITc67NsEEA:10 a=YuDzNgjKNNjrUeICi5sA:9 a=QEXdDO2ut3YA:10 a=Wm8N4nQisXyE0hqNaTxyMw==:117 X-Cloudmark-Score: 0 Date: Sun, 16 Sep 2012 17:46:50 +0000 From: To: python-list@python.org Subject: RE: Moving folders with content MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) Sensitivity: Normal X-Originating-IP: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347817614 news.xs4all.nl 6927 [2001:888:2000:d::a6]:45696 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29340 Hi "Nobody" and Hans, I really appreciate you all sharing this insight with me. > You might think that os.path.expanduser > would never expand '~' to something containing a double quote, > but you'd be wrong: > >>> import os > >>> os.environ['HOME'] = 'gotcha!"; rm -rf ' > >>> print(os.path.expanduser('~/Desktop/IN/Test/')) > gotcha!"; rm -rf /Desktop/IN/Test/ > > It's easy and safer to avoid using 'shell=True' option: > > cmd = ['ditto', '-vV', p1, p2] > v = subprocess.check_output(cmd, shell=False) I would have never thought about this, and this could definitely give me problems. Thank you for this advice! Again, thank you both for the examples and deeper understanding of how subprocess works. I will definitely start passing a list as the first argument as well as updating my older code to do the same. Jay