execv multiple executables in single python script? -


from can tell, execv overtakes current process, , once called executable finishes, program terminates. want call execv multiple times within same script, because of this, cannot done.

is there alternative execv runs within current process (i.e. prints same stdout) , won't terminate program? if so, it?

yes, use subprocess.
os.execv* not approporiate task, doc:

these functions execute new program, replacing current process; not return. on unix, new executable loaded current process, , have same process id caller.

so, want external exe print same output, might do:

import subprocess output = subprocess.check_output(['your_exe', 'arg1']) 

by default, check_output() returns output written standard output. if want both standard output , error collected, use stderr argument.

output = subprocess.check_output(['your_exe', 'arg1'], stderr=subprocess.stdout) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -