Issue
I want to execute a batch file by calling it from a python script. The thing is that this batch needs JAVA_HOME to be set. I don't want to set this variable in the system env Variable, i want to do it from python. Is there anyway to execute two batch commands via Like this
p = Popen("""set JAVA_HOME=D:\GIT\G_ATC_FCT_SW_HSM_Daimler\Tools\jdk-8.0.242.08-hotspot;D:\\GIT\\G_ATC_FCT_SW_HSM_Daimler\\Tools\\plugins\\com.nxp.id.jcop.eclipse_6.0.0.8\\cmds\\converter.bat Java_Card_Converter-3.0.5""")
stdout, stderr = p.communicate()
But i got this error FileNotFoundError: [WinError 2] The specified file could not be found
.
Is it possible to do it from popen ?
Solution
The response provided by @GPhilo helped me. Here is solution to my problem:
Then since you don't actually need to run two commands, but only run the script with a modified environment, use the solution from here: Python subprocess/Popen with a modified environment – GPhilo
Answered By - Lyes kheffache
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.