i'm trying to run:

 try:
    with open(subprocess.PIPE, 'w') as pipe:
          call(["/usr/sbin/atms","-k"], stdout=pipe, stderr=pipe)                                        
          call(["/usr/sbin/atms","/usr/sbin/atms.conf"],stdout=pipe,stder=pipe)
 except Exception, e:
          print e

I now get

 coercing to Unicode: need string or buffer, int found

What does it mean?

Thanks

有帮助吗?

解决方案

open() is used for files, and expects a filename not a pipe.

Instead of .call(), you could use Popen:

>>> p = subprocess.Popen(['python', '-c', 'print "test"'], stdout=subprocess.PIPE)
>>> p.stdout.read()
'test\r\n'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top