execute bash builtins in python
alex goretoy
agoretoy at gmail.com
Fri Mar 12 01:52:15 EST 2010
hi,
i'm trying to write a section of my program that needs to run bash builtin
alias and declare, i've googled and tried every type of example i could find
no to avail. this is what I've tried below and it doesn't work, is there a
way for me to execute a bah builin from python? what i need is to take alias
output and pipe it to another command with python and return the results to
a string or list.
>>> p1=Popen(["alias"],stdout=PIPE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/subprocess.py", line 621, in __init__
errread, errwrite)
File "/usr/lib/python2.6/subprocess.py", line 1126, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
if i add shell=True i get empty string and no thins error message
>>> p1=Popen(["alias"],stdout=PIPE,shell=True)
>>> p1
<subprocess.Popen object at 0xb7589a4c>
>>> p1.stdout.read()
''
thank you,
-Alex Goretoy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100312/e4d21557/attachment.html>
More information about the Python-list
mailing list