Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29340 > unrolled thread

RE: Moving folders with content

Started by<jyoung79@kc.rr.com>
First post2012-09-16 17:46 +0000
Last post2012-09-16 17:46 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  RE: Moving folders with content <jyoung79@kc.rr.com> - 2012-09-16 17:46 +0000

#29340 — RE: Moving folders with content

From<jyoung79@kc.rr.com>
Date2012-09-16 17:46 +0000
SubjectRE: Moving folders with content
Message-ID<mailman.808.1347817614.27098.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web