I read that os.system() shall be replaced by subprocess.call(), so I tried to use that. I am reading environment variables with
parallelrun = os.environ['PARALLEL_RUN']
aims = os.environ['AIMS_COMMAND']
and want to run it then with
with open(outfile, 'w') as f:
subprocess.call([parallelrun, aims], stdout=f)
I haven't saved the error message, but it seemed to fail somewhere in the subprocess module. I think running it with shell=True
works but makes the script more vulnerable.
I do not understand why the variables which were specified in the same script do not expand without the shell. Any ideas?