Hi,
I would like to execute a command similar to the description of exec() in the documentation: exec("open", path). This works correctly when "path" points to a document that knows its creator (like Excel in case of results.xls) When specifying any other application, I succeeded in OS X Terminal: open "/Users/norbert/EightDots.txt" -a "/Applications/Igor Pro 6.2 Folder/Igor Pro.app" However, I cannot get it run from ImageJ. My text file, which immediately draws a publication quality graph, looks like this: IGOR WAVES/O xValues,yValues BEGIN 3.0955 1.8882 1.9475 1.0004 2.7004 0.8494 2.3837 0.9058 2.7065 1.0626 1.9577 0.8763 1.5672 0.9094 1.7842 0.9633 END X Display yValues vs xValues X Modify grid=1 X ModifyGraph mode=2 X SetAxis left 0,2 X SetAxis bottom 0,4 X ModifyGraph lsize=7 Norbert Vischer -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Norbert,
it seems that the spaces in the file name are the culprit; I tried 'open -a' commands where with no spaces in the names and using no quotes for the names and it always works. What might help is replacing each space with its octal representation, omitting the quotes for the arguments and let ImageJ split it at the correct points (whitespace characters): exec("open /Users/norbert/EightDots.txt -a /Applications/Igor\040Pro\0406.2 Folder/Igor\040Pro.app"); You could also try splitting the string yourself at the right points; if there are several arguments, ImageJ does not spit the individual arguments any more, even if they contain whitespace: exec("open", "/Users/norbert/EightDots.txt", "-a", "/Applications/Igor Pro 6.2 Folder/Igor Pro.app"); [I don't have Igor Pro, so I can't try myself. I think that in theory, both possibilities should work.] The background: When you type a command in the terminal, the shell takes care of removing the quotes while keeping everything inside the quotes together, but splitting the arguments at whitespace boundaries that were not inside any quotes. Then, the first argument is taken as program name, and the program gets an array of arguments that have been split by the shell. [For the Windows guys out there: the shell is the command interpreter in unix/linux-style systems] Michael ________________________________________________________________ On Jan 20, 2015, at 00:17, Norbert Vischer wrote: > Hi, > > I would like to execute a command similar to the description of exec() in the documentation: > exec("open", path). > This works correctly when "path" points to a document that knows its creator (like Excel in case of results.xls) > > > When specifying any other application, I succeeded in OS X Terminal: > open "/Users/norbert/EightDots.txt" -a "/Applications/Igor Pro 6.2 Folder/Igor Pro.app" > > However, I cannot get it run from ImageJ. > > > My text file, which immediately draws a publication quality graph, looks like this: > > IGOR > WAVES/O xValues,yValues > BEGIN > 3.0955 1.8882 > 1.9475 1.0004 > 2.7004 0.8494 > 2.3837 0.9058 > 2.7065 1.0626 > 1.9577 0.8763 > 1.5672 0.9094 > 1.7842 0.9633 > END > X Display yValues vs xValues > X Modify grid=1 > X ModifyGraph mode=2 > X SetAxis left 0,2 > X SetAxis bottom 0,4 > X ModifyGraph lsize=7 > > > Norbert Vischer > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
> On Jan 20, 2015, at 00:17, Norbert Vischer wrote: > >> Hi, >> >> I would like to execute a command similar to the description of exec() in the documentation: >> exec("open", path). >> This works correctly when "path" points to a document that knows its creator (like Excel in case of results.xls) >> >> >> When specifying any other application, I succeeded in OS X Terminal: >> open "/Users/norbert/EightDots.txt" -a "/Applications/Igor Pro 6.2 Folder/Igor Pro.app" >> >> However, I cannot get it run from ImageJ. > You could also try splitting the string yourself at the right points; if there are several arguments, ImageJ does not spit the individual arguments any more, even if they contain whitespace: > exec("open", "/Users/norbert/EightDots.txt", "-a", "/Applications/Igor Pro 6.2 Folder/Igor Pro.app"); > This works- and it is the most straight-forward method, so I didn't need to replace any spaces. Wayne, perhaps this example could find its way into the documentation of exec() ? Thanks a lot for this solution and best regards, Norbert -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |