I have a nonpython program I am running with python using the os.system command, but I put this command inside a function. The program I want to run with os.system is supposed to give me an output file, and I need that output for processing, also I need that output to be actually written in the directory I am sending it to.
I wrote my function is the following general format
def myFunction(infile):
os.system('myProgram '+infile+' '+outfileName)
outfile = numpy.loadtxt(outfileName)
return outfile
However, the output of myProgram (outfileName) isn't being written to my directory and numpy can't therefore load it. Is there a way to store globally outputs of programs I run using os.system when it's inside a function?
outfileName? Is that variable in the scope of this function?outfileNameto make sure it's where you want it to be. Or, can you havemyProgramoutput to STDOUT?os.system('cp test test2')and it worked fine. Can you substitute something like that and try it for sanity testing. Also,print(repr('myProgram '+infile+' '+outfileName))and post that here for us to see. And of course...retval = os.system('myProgram '+infile+' '+outfileName)and test the program for a nonzero return code!