Q:

python call to popen.communicate gives no output

I have a class function declared as 
    def catFunc(self,filename):
    print "catFunc",filename
    process = subprocess.Popen(['cat',/root/scratch.php], stdout=subprocess.PIPE, shell=True)
    out, err = process.communicate()
    print (out)
    print (err)

and called like this
fn = '/root/scratch.php'
self.catFunc(fn)

But I see no output and cannot figure out why
Any help greatly appreciated

A:

To read content of file 
def catFunc(self,filename):
    with open(filename) as f:
        s = f.read()
    return s

If you need to use the subprocess module:
import subprocess

def catFunc(filename):
    print "catFunc"
    task = subprocess.Popen(["cat", filename], stdout=subprocess.PIPE)
    print list(task.stdout)

catFunc()

