Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'strings.': 0.07; 'verbatim': 0.07; 'python': 0.09; 'grep': 0.09; 'parameter.': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; "'q'": 0.16; 'filename:fname piece:signature': 0.16; 'rough': 0.16; 'subprocess': 0.16; 'wrote:': 0.17; 'equivalent': 0.20; 'import': 0.21; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'kumar': 0.29; 'recommended': 0.33; 'received:192.168.2': 0.34; 'correctly': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'cut': 0.71; 'pipeline': 0.84; 'to:addr:yahoo.co.in': 0.91 Date: Mon, 30 Jul 2012 12:35:38 +0200 From: Philipp Hagemeister User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.5) Gecko/20120624 Icedove/10.0.5 MIME-Version: 1.0 To: Vikas Kumar Choudhary Subject: Re: Linux shell to python References: <1343631941.7199.YahooMailNeo@web193104.mail.sg3.yahoo.com> In-Reply-To: <1343631941.7199.YahooMailNeo@web193104.mail.sg3.yahoo.com> X-Enigmail-Version: 1.4 OpenPGP: id=FAFB085C Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigAF63AA5367E1A0A6E47C04EE" Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343644555 news.xs4all.nl 6952 [2001:888:2000:d::a6]:52959 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26242 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAF63AA5367E1A0A6E47C04EE Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/30/2012 09:05 AM, Vikas Kumar Choudhary wrote: > `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2" | cut -c1-7' The rough Python equivalent would be import subprocess [ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim for l in subprocess.check_output(['lspci']).splitlines() if 'Q' in l and isp_str1 in l and isp_str2 in l ] You can also just paste the whole pipeline with the shell=3DTrue parameter. That's not recommended though, and it's hard to correctly quote strings. - Philipp --------------enigAF63AA5367E1A0A6E47C04EE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEAREKAAYFAlAWY3wACgkQ9eq1gvr7CFykBQCeNC7F/jZP8xOWwLvKGruTOhpy sWYAoI44zaEeM5qKwX2tdH3ZuuFpgrwb =8rax -----END PGP SIGNATURE----- --------------enigAF63AA5367E1A0A6E47C04EE--