Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26233
| References | <1343631941.7199.YahooMailNeo@web193104.mail.sg3.yahoo.com> |
|---|---|
| Date | 2012-07-30 17:40 +1000 |
| Subject | Re: Linux shell to python |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2716.1343634007.4697.python-list@python.org> (permalink) |
On Mon, Jul 30, 2012 at 5:05 PM, Vikas Kumar Choudhary <vikas.choudhary@yahoo.co.in> wrote: > > I was trying porting from bash shell to python. > > let me know if someone has tried to implement (grep and PIPE) shell commands in python `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2" | cut -c1-7' Welcome! While it's technically possible to do exactly that in Python (using subprocess as you describe), there's usually a more efficient and cleaner method of achieving the same goal. With a port such as you describe, it's probably best to go right back to the conceptual level and work out what exactly you're trying to do, and then look at implementing that in Python. You'll end up with much cleaner code at the end of it. For an initial guess, I would say that you'll use subprocess to invoke lspci, but then everything else will be done in Python directly. ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Linux shell to python Chris Angelico <rosuav@gmail.com> - 2012-07-30 17:40 +1000 Re: Linux shell to python 张少华 <zhangshaohua20101010@gmail.com> - 2012-07-30 04:09 -0700
csiph-web