Python Forum

Full Version: yet another code that works on 2 but not in 3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all
sorry for bothering with a similar problem but this time the trick Gribouillis gave me does not
work. The code below sends the input to a process created with subporcess.call() using a file descriptor generated with os.pipe(). It works with python 2 but not with python 3 and this time
including "os.set_inheritable(r,True)" does not work, i.e. the subprocess does not receive the input.

Any ideas

thanks in advance

import subprocess as sp


(r,w) = os.pipe()
#os.set_inheritable(r,True)

pipe = os.fdopen(w, 'w', -1)

pipe.write('title "TEST"\n')
pipe.flush()

f=sp.call(['xmgrace','-dpipe',repr(r),])
Have you tried the -pipe option to read data from stdin or -npipe to read data from a named pipe as indicated in the man page?