I trying to run exec file from python, and to get the output immediately to the screen and to variable, and also to get the return code.
When I use the commnd "os.system(cmd)" ,I get the output to the screen, but I cant get it to variable ( I get only the return code );
When I use the commnd "stat_output = commands.getstatusoutput(cmd)", I get the output and the return code to var.
but if I want to get the output to the screen I need to wait until the command is ended.
How can I get the output immediately to the screen, and also to var?
Thanks in advance