I'm writing script to generate Autosys report using Python 2.6, and I would like to pass variables from python script to bash command:
I have 3 variables:
NextMonth, NDNextMonth, Year
When I'm using the command with 1 varibale, it works properly.
env = os.environ.copy()
env['NextMonth'] = NextMonth
subprocess.call('forecast -J *JobABC_* -M ALL -F "${NextMonth}/01/2020 00:00" -T "${NextMonth}/31/2020 23:59" -h -n > PythonReport1.txt', env=env, shell=True)
In the opposite way, it does not work, date is not valid:
env = os.environ.copy()
env['NextMonth'] = NextMonth
env['NDNextMonth'] = NDNextMonth
env['Year'] = Year
subprocess.call('forecast -J *JobABC_* -M ALL -F "${NextMonth}/01/${Year}" 00:00" -T "${NextMonth}/${NDNextMonth}/${Year}" 23:59" -h -n > PythonReport1.txt',env=env, shell=True)
Could you please check, how to read those 3 variables into the command? Error: TypeError: execve() arg 3 contains a non-string value