The java project I am working on has a .bat file and a .sh file which build the CLASSPATH for the project to run. (.bat for windows and .sh for the rest).
Now, I am writing a python script that needs access to the classpath created by these scripts, the one from .sh if on linux and the one from .bat if on windows.
Currently, I am doing this for linux:
Popen(['bash', '-c', '. mkcp.sh && echo $CLASSPATH'], stdout=sp.PIPE).communicate()[0].strip()
And I can't figure out an equivalent way to do this on windows. So far I've come up with this
check_output(['cmd', '/c', 'call mkcp.bat && echo %CLASSPATH%'])
But that puts all the commands in the mkcp.bat file into the stdout. (Adding @echo off to that file is not an option for me, i.e., I can't modify it). That problem aside, the main problem is that the %CLASSPATH% is substituted with its value before the batch file is run, which is not what I want.
Another approach I thought of was if I create a Popen object as above and run the batch file and if I can access the environment of that process, I can get what I want. But from Popen's documentation, this doesn't look to be possible.
Any ideas on how to achieve this?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)