내가 이것을 실행할 때
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
);bat 파일 실행을 위한 작업 디렉토리는 내 데스크탑 디렉토리인 것 같습니다. 나는 파이썬이 작업 디렉토리를 사용하여 명령줄에서도 파일 이름을 찾을 것이라고 생각합니다. 전체 경로 이름을 사용하는 것이 좋은 선택인 것 같습니다.
https://superuser.com/questions/396394/how-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex 시작 명령에서 작업 디렉토리를 지정할 수 있다고 제안합니다.
START /D c:\temp notepad.exe
내가 하고 있는 중첩 호출과 관련된 문제가 있습니다.
RunProgram() --> cmd --> 파이썬
다음 박쥐 파일은 완벽하게 작동합니다.
set JMP_PYTHON_PTH=%UserProfile%\miniconda_JMP\
CALL %JMP_PYTHON_PTH%\Scripts\activate.bat %JMP_PYTHON_PTH%
start /B /wait "" python test.py
그러나 RunProgram()을 사용할 때 Python 파일에 절대 경로를 추가하지 않으면 코드가 실패합니다(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
);절대 경로가 제공되지 않은 경우에만 내가 얻는 오류는 다음과 같습니다.
(base) C:\WINDOWS\system32>start /B /wait \!"\!" python test.py
python: can't open file 'test.py': [Errno 2] No such file or directory