Shell Commands in Python Code
Paul Watson
pwatson at redlinepy.com
Sat May 7 13:01:48 EDT 2005
"Sara Khalatbari" <sarapythonlist at yahoo.com> wrote in message
news:mailman.144.1115481338.29826.python-list at python.org...
> There are a lot of commands that I need to use in my
> code & I don't know how to do it
>
> Is there a way to use shell commands in Python code?
Yes, there are many popen() forms that you may wish to investigate. Below
is a brief clip. However, if you can find the functionality already built
into Python, such as globbing filenames, that would be better. It will be
more portable to more systems and probably faster.
x = os.popen("ls -al")
for aline in x.readlines():
print aline,
More information about the Python-list
mailing list