Nov-29-2019, 08:44 AM
Hi everyone
this is Pedro and this is my first post. I am trying to write a script to make graphs with xmgrace (graphics program) under linux. There are serveral modules available on the net but none of them work with python 3.
In general terms what I want to do is to launch a process that receives input through a descriptor, in my case the command is 'xmgrace -dpipe <descriptor>'. I wrote the code below that works fine in python 2 but does nothing in python 3.
Any ideas of what's wrong?
Thank you in advance
this is Pedro and this is my first post. I am trying to write a script to make graphs with xmgrace (graphics program) under linux. There are serveral modules available on the net but none of them work with python 3.
In general terms what I want to do is to launch a process that receives input through a descriptor, in my case the command is 'xmgrace -dpipe <descriptor>'. I wrote the code below that works fine in python 2 but does nothing in python 3.
Any ideas of what's wrong?
Thank you in advance
import os cmd=('xmgrace','-noask','-dpipe',) fr,fw=os.pipe() cmd=cmd+(repr(fr),) pid=os.fork() if pid==0: for i in range(64): if i not in (fr,0,1,2): try: os.close(i) except OSError: pass os.execvp('xmgrace',cmd) else: os.close(fr) pipe=os.fdopen(fw,'w',1) pipe.write('title "test"\n') pipe.flush()