cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-337927%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Run%20Program()%EC%9C%BC%EB%A1%9C%20Python%20%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8%20%EC%8B%A4%ED%96%89%ED%95%98%EA%B8%B0%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-337927%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%EB%82%B4%EA%B0%80%20%EC%9D%B4%EA%B2%83%EC%9D%84%20%EC%8B%A4%ED%96%89%ED%95%A0%20%EB%95%8C%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Efile_path%20%3D%20convertfilepath(%22%24temp%2Fx.bat%22%2C%22windows%22)%3B%0Asavetextfile(file_path%2C%20%22dir%5C!n%22)%3B%0A%0Arp%20%3D%20RunProgram(%20Executable(%20%22cmd.exe%22%20)%2C%0A%20Options(%20%7B%22%2FC%22%2C%20file_path%7D%20)%2C%0A%20ReadFunction(%22text%22)%20%2F%2F%20returns%20all%20text%20%0A%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ebat%20%ED%8C%8C%EC%9D%BC%20%EC%8B%A4%ED%96%89%EC%9D%84%20%EC%9C%84%ED%95%9C%20%EC%9E%91%EC%97%85%20%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC%EB%8A%94%20%EB%82%B4%20%EB%8D%B0%EC%8A%A4%ED%81%AC%ED%83%91%20%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC%EC%9D%B8%20%EA%B2%83%20%EA%B0%99%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EB%82%98%EB%8A%94%20%ED%8C%8C%EC%9D%B4%EC%8D%AC%EC%9D%B4%20%EC%9E%91%EC%97%85%20%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EB%AA%85%EB%A0%B9%EC%A4%84%EC%97%90%EC%84%9C%EB%8F%84%20%ED%8C%8C%EC%9D%BC%20%EC%9D%B4%EB%A6%84%EC%9D%84%20%EC%B0%BE%EC%9D%84%20%EA%B2%83%EC%9D%B4%EB%9D%BC%EA%B3%A0%20%EC%83%9D%EA%B0%81%ED%95%A9%EB%8B%88%EB%8B%A4.%20%EC%A0%84%EC%B2%B4%20%EA%B2%BD%EB%A1%9C%20%EC%9D%B4%EB%A6%84%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%20%EA%B2%83%EC%9D%B4%20%EC%A2%8B%EC%9D%80%20%EC%84%A0%ED%83%9D%EC%9D%B8%20%EA%B2%83%20%EA%B0%99%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fsuperuser.com%2Fquestions%2F396394%2Fhow-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fsuperuser.com%2Fquestions%2F396394%2Fhow-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex%3C%2FA%3E%20%EC%8B%9C%EC%9E%91%20%EB%AA%85%EB%A0%B9%EC%97%90%EC%84%9C%20%EC%9E%91%EC%97%85%20%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC%EB%A5%BC%20%EC%A7%80%EC%A0%95%ED%95%A0%20%EC%88%98%20%EC%9E%88%EB%8B%A4%EA%B3%A0%20%EC%A0%9C%EC%95%88%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ESTART%20%2FD%20c%3A%5Ctemp%20notepad.exe%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-337888%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERun%20Program()%EC%9C%BC%EB%A1%9C%20Python%20%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%A8%20%EC%8B%A4%ED%96%89%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-337888%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%EB%82%B4%EA%B0%80%20%ED%95%98%EA%B3%A0%20%EC%9E%88%EB%8A%94%20%EC%A4%91%EC%B2%A9%20%ED%98%B8%EC%B6%9C%EA%B3%BC%20%EA%B4%80%EB%A0%A8%EB%90%9C%20%EB%AC%B8%EC%A0%9C%EA%B0%80%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERunProgram()%20--%26gt%3B%20cmd%20--%26gt%3B%20%ED%8C%8C%EC%9D%B4%EC%8D%AC%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%EB%8B%A4%EC%9D%8C%20%EB%B0%95%EC%A5%90%20%ED%8C%8C%EC%9D%BC%EC%9D%80%20%EC%99%84%EB%B2%BD%ED%95%98%EA%B2%8C%20%EC%9E%91%EB%8F%99%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eset%20JMP_PYTHON_PTH%3D%25UserProfile%25%5Cminiconda_JMP%5C%0A%0ACALL%20%25JMP_PYTHON_PTH%25%5CScripts%5Cactivate.bat%20%25JMP_PYTHON_PTH%25%0A%0Astart%20%2FB%20%2Fwait%20%22%22%20python%20test.py%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%EA%B7%B8%EB%9F%AC%EB%82%98%20RunProgram()%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%A0%20%EB%95%8C%20Python%20%ED%8C%8C%EC%9D%BC%EC%97%90%20%EC%A0%88%EB%8C%80%20%EA%B2%BD%EB%A1%9C%EB%A5%BC%20%EC%B6%94%EA%B0%80%ED%95%98%EC%A7%80%20%EC%95%8A%EC%9C%BC%EB%A9%B4%20%EC%BD%94%EB%93%9C%EA%B0%80%20%EC%8B%A4%ED%8C%A8%ED%95%A9%EB%8B%88%EB%8B%A4(test.py%20--%26gt%3B%20'C%3A%2Fa%2Fb%2Fc%2Ftest.py').%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EClearLog()%3B%0A%0Afile_path%20%3D%20ConvertFilePath(%20%22.%2Ftests%2Frun_python_installation_test.bat%22%2C%20windows)%3B%0A%0Arp%20%3D%20RunProgram(%20Executable(%20%22cmd.exe%22%20)%2C%0A%20Options(%20%7B%22%2FC%22%2C%20file_path%7D%20)%2C%0A%20ReadFunction(%22text%22)%20%2F%2F%20returns%20all%20text%20%0A%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%EC%A0%88%EB%8C%80%20%EA%B2%BD%EB%A1%9C%EA%B0%80%20%EC%A0%9C%EA%B3%B5%EB%90%98%EC%A7%80%20%EC%95%8A%EC%9D%80%20%EA%B2%BD%EC%9A%B0%EC%97%90%EB%A7%8C%20%EB%82%B4%EA%B0%80%20%EC%96%BB%EB%8A%94%20%EC%98%A4%EB%A5%98%EB%8A%94%20%EB%8B%A4%EC%9D%8C%EA%B3%BC%20%EA%B0%99%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E(base)%20C%3A%5CWINDOWS%5Csystem32%26gt%3Bstart%20%2FB%20%2Fwait%20%5C!%22%5C!%22%20python%20test.py%20%0Apython%3A%20can't%20open%20file%20'test.py'%3A%20%5BErrno%202%5D%20No%20such%20file%20or%20directory%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-337888%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%EC%9E%90%EB%8F%99%ED%99%94%20%EB%B0%8F%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8C%85%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%EB%8D%B0%EC%9D%B4%ED%84%B0%20%EC%A0%91%EA%B7%BC%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%ED%92%88%EC%A7%88%20%EB%B0%8F%20%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4%20%EC%97%94%EC%A7%80%EB%8B%88%EC%96%B4%EB%A7%81%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Choose Language Hide Translation Bar
FN
FN
Level VI

Executing Python programs with Run Program()

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Executing Python programs with Run Program()

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...  suggests you can specify the working directory in your start command:

START /D c:\temp notepad.exe

 

Craige

View solution in original post

1 REPLY 1
Craige_Hales
Super User

Re: Executing Python programs with Run Program()

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...  suggests you can specify the working directory in your start command:

START /D c:\temp notepad.exe

 

Craige

Recommended Articles