Problem with exec() argument string...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with exec() argument string...

Bill Mohler
Hi Wayne and others-

This works in Terminal to run my macro with a compound-string argument.

java -Xmx500m -jar /Applications/ImageJ/ij.jar -ijpath
/Applications/ImageJ/ -port0 -macro /Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/MuscleToneBatchSegmentationMacro_092011.ijm
1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5


but this line in a macro

exec('java -Xmx500m -jar /Applications/ImageJ/ij.jar -ijpath
/Applications/ImageJ/ -port0 -macro /Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/MuscleToneBatchSegmentationMacro_092011.ijm
1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5');

gives this error:

    Macro or script not found:

    /Volumes/Mohler_FTP/MUSCLE.txt


So does

exec("java -Xmx500m -jar /Applications/ImageJ/ij.jar -ijpath
/Applications/ImageJ/ -port0 -macro /Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/MuscleToneBatchSegmentationMacro_092011.ijm
1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5");



Clearly exec() handles escaped spaces differently than my bash command
line does.
Is there a way to handle paths with spaces in exec() that I'm forgetting?

Thanks,
Bill
Reply | Threaded
Open this post in threaded view
|

Re: Problem with exec() argument string...

Bill Mohler
http://rsbweb.nih.gov/ij/macros/ExecExamples.txt

This line works!

exec("java", "-Xmx500m", "-jar", "/Applications/ImageJ/ij.jar",
"-ijpath", "/Applications/ImageJ/", "-port0", "-macro",
"/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/MuscleToneBatchSegmentationMacro_092011.ijm",
"1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5");

On 9/21/11 10:29 a.m., Bill Mohler wrote:

> Hi Wayne and others-
>
> This works in Terminal to run my macro with a compound-string argument.
>
> java -Xmx500m -jar /Applications/ImageJ/ij.jar -ijpath
> /Applications/ImageJ/ -port0 -macro /Volumes/Mohler_FTP/MUSCLE\ QUALITY\
> STUDY/MuscleToneBatchSegmentationMacro_092011.ijm
> 1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
> STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5
>
>
> but this line in a macro
>
> exec('java -Xmx500m -jar /Applications/ImageJ/ij.jar -ijpath
> /Applications/ImageJ/ -port0 -macro /Volumes/Mohler_FTP/MUSCLE\ QUALITY\
> STUDY/MuscleToneBatchSegmentationMacro_092011.ijm
> 1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
> STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5');
>
> gives this error:
>
>      Macro or script not found:
>
>      /Volumes/Mohler_FTP/MUSCLE.txt
>
>
> So does
>
> exec("java -Xmx500m -jar /Applications/ImageJ/ij.jar -ijpath
> /Applications/ImageJ/ -port0 -macro /Volumes/Mohler_FTP/MUSCLE\ QUALITY\
> STUDY/MuscleToneBatchSegmentationMacro_092011.ijm
> 1\,1\,2\,2\,1\,/Volumes/Mohler_FTP/MUSCLE\ QUALITY\
> STUDY/710-206/ZSeries-09162011-0956-032/\,ZSeries-09162011-0956-032\,5");
>
>
>
> Clearly exec() handles escaped spaces differently than my bash command
> line does.
> Is there a way to handle paths with spaces in exec() that I'm forgetting?
>
> Thanks,
> Bill
>