BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
AT
AT
Community Trekker

How do you Pass Arguments from JMP to Python script?

Hi,

I like to pass a string (file name) to a Python Script using RunProgram. Here is the script:

 

 

file = "mtest.py abc.pdf";

 

RunProgram(executable("/usr/bin/python"),options({file}),readfunction("text"));

 

I appreciate your help. Thanks.

0 Kudos
2 ACCEPTED SOLUTIONS

Accepted Solutions
ih
ih
Community Trekker

Re: How to Pass Arguments from JMP to Python script?

You need to pass two different arguments through RunProgram as a list, because you are actually passing two arguments to python.  I do not have a mac, but on windows this python script:

import sys
print(sys.argv[1])

 

and this jsl script:

RunProgram(
	executable("C:\path to\python.exe"),
	options({"C:/path to/pythonscript.py", "hi"}),
	readfunction("text")
);

 

returns:

"hi
"

Re: How to Pass Arguments from JMP to Python script?

Keep an eye out for JMP 14.0 and the new Python Submit() command.

It will allow you to call Python code directly from JSL, passing and receiving data structures - no RunProgram() required.

4 REPLIES 4
ih
ih
Community Trekker

Re: How to Pass Arguments from JMP to Python script?

You need to pass two different arguments through RunProgram as a list, because you are actually passing two arguments to python.  I do not have a mac, but on windows this python script:

import sys
print(sys.argv[1])

 

and this jsl script:

RunProgram(
	executable("C:\path to\python.exe"),
	options({"C:/path to/pythonscript.py", "hi"}),
	readfunction("text")
);

 

returns:

"hi
"
AT
AT
Community Trekker

Re: How to Pass Arguments from JMP to Python script?

Thanks. I will give it a try.

0 Kudos

Re: How to Pass Arguments from JMP to Python script?

Keep an eye out for JMP 14.0 and the new Python Submit() command.

It will allow you to call Python code directly from JSL, passing and receiving data structures - no RunProgram() required.

AT
AT
Community Trekker

Re: How to Pass Arguments from JMP to Python script?

 


Thanks. It is good to know.

0 Kudos