Runprogram with Space Char in FilePathHello 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
Advanced Statistical ModelingConsumer and Market ResearchQuality and Process EngineeringRe: Runprogram with Space Char in FilePathHi Craige,
thank you very much - actually I saw the post but didn't manage to adapt it.
Thanks again, works perfectly !
Re: Runprogram with Space Char in FilePathPrevious comment on using quotation marks: https://community.jmp.com/t5/Discussions/Unable-to-parse-speechmarks-quot-quot-into-powershell-using/m-p/245968/highlight/true#M48328
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 spacesUse 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.