cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
D_G
D_G
Level II

Runprogram with Space Char in FilePath

Hello everyone,

 

currently I'm struggeling with executing a runprogram command with a filepath containing a space char:

 

myPath = "C:\Users\FilePath\Test.py"
myInfo = runprogram(executable("python"), options({myPath}),readfunction("text"));

 

This works perfetly, but when the filepath contains a space - the path is cut off, thus the file cannot be found:

 

myPath = "C:\Users\File Path\Test.py"
myInfo = runprogram(executable("python"), options({myPath}),readfunction("text"));

Maybe someone can help me - thanks,

DG

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Runprogram with Space Char in FilePath

Previous comment on using quotation marks: https://community.jmp.com/t5/Discussions/Unable-to-parse-speechmarks-quot-quot-into-powershell-using... 

 

You can use a CMD window (the black DOS box window) to see how windows wants the command done with quotation marks:

Use quotation marks around parameters with embedded spacesUse quotation marks around parameters with embedded spaces

Once you have that working, you need to bring it in to a JMP string, which requires some sort of escaping since JMP also uses quotation marks. For this example, just escape the two quotation marks using \!"

 

filename = "c:\Program Files\Common Files\System\Ole DB\oledbjvs.inc";
write("filename = ", filename); // no quotation marks

txt = runprogram(executable("python"), options({
	"\!"" || filename || "\!""
}),readfunction("text"));

Use the "write" function in JMP, not the "print" function which adds more confusion by wrapping the printed text with quotation marks.

You could also build the quotation marks into the string, but the JSL above is what you need if you get the filename from something like the filesInDirectory function...you still need to add them. You can add quotation marks even if they are not needed. See the link at the top if you have quotation marks in the middle of the file name for some reason.

 

Craige

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: Runprogram with Space Char in FilePath

Previous comment on using quotation marks: https://community.jmp.com/t5/Discussions/Unable-to-parse-speechmarks-quot-quot-into-powershell-using... 

 

You can use a CMD window (the black DOS box window) to see how windows wants the command done with quotation marks:

Use quotation marks around parameters with embedded spacesUse quotation marks around parameters with embedded spaces

Once you have that working, you need to bring it in to a JMP string, which requires some sort of escaping since JMP also uses quotation marks. For this example, just escape the two quotation marks using \!"

 

filename = "c:\Program Files\Common Files\System\Ole DB\oledbjvs.inc";
write("filename = ", filename); // no quotation marks

txt = runprogram(executable("python"), options({
	"\!"" || filename || "\!""
}),readfunction("text"));

Use the "write" function in JMP, not the "print" function which adds more confusion by wrapping the printed text with quotation marks.

You could also build the quotation marks into the string, but the JSL above is what you need if you get the filename from something like the filesInDirectory function...you still need to add them. You can add quotation marks even if they are not needed. See the link at the top if you have quotation marks in the middle of the file name for some reason.

 

Craige
D_G
D_G
Level II

Re: Runprogram with Space Char in FilePath

Hi Craige,

thank you very much - actually I saw the post but didn't manage to adapt it.
Thanks again, works perfectly !