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


Groups > de.comp.lang.python > #4795

Re: [Python-de] os.system und os.popen

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Stefan Schwarzer <sschwarzer@sschwarzer.net>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] os.system und os.popen
Date Thu, 25 May 2017 20:01:59 +0200
Lines 30
Message-ID <mailman.55.1495736107.8815.python-de@python.org> (permalink)
References <c19f4a3f-fcf3-185a-574b-27e7cbeb56aa@fam-goebel.de> <mailman.46.1495726174.8815.python-de@python.org> <eooc7gFaul8U1@mid.individual.net> <5d4200a7-d838-9135-8aba-17bc4fe8a036@mail.de> <5d880bc4-41ef-5566-2f8e-17a7a447b23e@sschwarzer.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de uAmOIN2iE+CSuh4rWlmpfQql9JUomONBQ99kuU/tCTwA==
Return-Path <sschwarzer@sschwarzer.net>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.24) Gecko/20100411 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
In-Reply-To <5d4200a7-d838-9135-8aba-17bc4fe8a036@mail.de>
Content-Language de-DE
X-Provags-ID V03:K0:AQWtOh/WbP+BzoNLY9lhk4D6jx9synBFpoVdLH1hGFoVSUxnLuk CtXrQ31FaMWwM40cYrN+ghfcsyjP9rDn2mDNSfCaV7W22I9Q/wgw5pXY5ieFjkDEdUziLWI PtXllsFaMueD1R3Tnun/Bw6R26ayJIRgK89OmdweTgqUOfIip0w/62/Uuh4pWdkuVl33y4v qfUGQ2BWS+ZazQ4NV+7NA==
X-UI-Out-Filterresults notjunk:1;V01:K0:NXPnaYoK06Y=:doI1YCElsI+ewW9+b/MzCH C3h+AX2pYFdcfQMHhhwx7nCZGSG3NYUi95hnoUn+JmBUXzJErpLiap9vO829GFDxbjKP14ERp cZoQPqWHQeME9xi4M1pPSLKItjuUP/+kxEaYbO6Tl6jIjQkiRGnwqnHV+DlbleS+ZOYGpD8Xq 9gi7klIwBc3EjpH06Nhc1DAdZRmNm9RdsiSMVOAhKNDmCD3ejKixJunAFtGOLWjz0hRrDhbLl DZ2/c54F0vrxtC7+hO8FBqkgM+SzNcD8qscfHZrVOfPiY13CM51HYUEv24ZDcwUduj6eeoFce yJi/hxhLjFaXMCwSksf71bKPAbF0kgzD0O7DDIM5zf+yzgEm2wIPE1xmYdAlci+ZS+LVRYt6P E4runwj/7GR02bSDjv9QO2yB5DI10o+tSljGc1IzunGNJpGbmS0NugB9cRh1a5EX4+NGGA9F1 NJHY2CwpO63ep7lbMv2yz6oWGoeJN/r9DM9HWz7fN/GzSXn6p0Aa6Q17Mb4soPGkIMvME8k7D 2kL7xldfamAG/VAxFty0OcU6EFvU/sfz0OyfCVwpt+IVIUEY0PUI2koDp47FIdjme/8o2et6E zL1U4F6WcQxiCedoxhQdb9hpkyjVqM9g3F5YAAePPdFDw480fytDg4vpSrl19wGm9uA8yggLh zmHywXF+dmOnGtsKOrBZ54A3UhhDhUpwn55e5+aw5u1/B7VowwZLBiNn7LxteQzuW3ZGQU2jy zc4KQPa4JJU2ZvzY
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <5d880bc4-41ef-5566-2f8e-17a7a447b23e@sschwarzer.net>
X-Mailman-Original-References <c19f4a3f-fcf3-185a-574b-27e7cbeb56aa@fam-goebel.de> <mailman.46.1495726174.8815.python-de@python.org> <eooc7gFaul8U1@mid.individual.net> <5d4200a7-d838-9135-8aba-17bc4fe8a036@mail.de>
Xref csiph.com de.comp.lang.python:4795

Show key headers only | View raw


On 2017-05-25 19:06, Sven R. Kunze wrote:> On 25.05.2017 17:40, Hermann Riemann wrote:
>> error=os.system("latex ... 2> /tmp/log")
>>
>> Hermann
>>    der das so machen würde
>>
>
> Sieht durchaus einfacher aus, ist aber nicht ganz unsicher, wenn's um
> das Thema Quoting von Parametern geht.
>
> *Hier auch noch zum Nachlesen:*
> https://docs.python.org/3.6/library/subprocess.html

`subprocess` ist nicht nur sicherer, sondern auch ganz
allgemein robuster.

Es wird zwar immer hervorgehoben, dass mit dem Modul keine
Angriffe mit speziellen Dateinamen möglich sind (was stimmt),
aber das Modul hilft auch, wenn zum Beispiel Dateinamen ganz
ohne böse Absicht Leerzeichen enthalten oder Zeichen, die
sonst von der Shell interpretiert werden würden.

Beispiel:

  dateiname = "dies & das.txt"  # von irgendwoher

  ausgabe = subprocess.check_output(["du", "--human-readable", "--summarize", dateiname])

Viele Grüße
Stefan

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

[Python-de] os.system und os.popen Ulrich Goebel <ml@fam-goebel.de> - 2017-05-25 17:19 +0200
  Re: [Python-de] os.system und os.popen Hermann Riemann <nospam.ng@hermann-riemann.de> - 2017-05-25 17:40 +0200
    Re: [Python-de] os.system und os.popen "Sven R. Kunze" <srkunze@mail.de> - 2017-05-25 19:06 +0200
    Re: [Python-de] os.system und os.popen Stefan Schwarzer <sschwarzer@sschwarzer.net> - 2017-05-25 20:01 +0200
    Re: [Python-de] os.system und os.popen Reimar Bauer <rb.proj@gmail.com> - 2017-05-25 23:30 +0200

csiph-web