When I run this
file_path = convertfilepath("$temp/x.bat","windows");
savetextfile(file_path, "dir\!n");
rp = RunProgram( Executable( "cmd.exe" ),
Options( {"/C", file_path} ),
ReadFunction("text") // returns all text
);it appears the working directory for the bat file execution is my desktop directory. I think python will use the working directory to find the filename on the command line too. Using the full path name seems a good choice.
https://superuser.com/questions/396394/how-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex suggests you can specify the working directory in your start command:
START /D c:\temp notepad.exe
I am having an issue that should be related to the nested calls I am doing.
RunProgram() --> cmd --> Python
The following bat file works perfectly fine.
set JMP_PYTHON_PTH=%UserProfile%\miniconda_JMP\
CALL %JMP_PYTHON_PTH%\Scripts\activate.bat %JMP_PYTHON_PTH%
start /B /wait "" python test.py
And yet, when using RunProgram() the code fails unless I add the absolute path to the Python file (test.py --> 'C:/a/b/c/test.py')
ClearLog();
file_path = ConvertFilePath( "./tests/run_python_installation_test.bat", windows);
rp = RunProgram( Executable( "cmd.exe" ),
Options( {"/C", file_path} ),
ReadFunction("text") // returns all text
);The error I get, again only if the absolute path is not given, is the following.
(base) C:\WINDOWS\system32>start /B /wait \!"\!" python test.py
python: can't open file 'test.py': [Errno 2] No such file or directory