How to Access Unix Shell

PaxDiablo nobody at nowhere.com
Mon Jun 14 05:58:50 CEST 2004


"Neale" <nhirsh2 at ieee.org> wrote in message
news:2d7af4f8.0406131648.42868c63 at posting.google.com...
> In a python program, I want to do a Unix directory list and then
> append selected files to each other which, as you know, is just  "cat
> filename2 >> filename1." How do I escape into the shell and then
> return, bringing with me a  directory list?


How about?
=====
import os
pipeLine = os.popen("ls -1","r")
curLine = pipeLine.readline()
while curLine:
        print "Got file [%s]"%(curLine[:-1])
        curLine = pipeLine.readline()
pipeLine.close()
=====


>
> Where can I find some examples of mixing shell commands and Python?






More information about the Python-list mailing list