Login  Register

Re: macro: Redirection in exec( UNIX-binary ) ?

Posted by Gluender-4 on Jul 28, 2010; 3:25pm
URL: http://imagej.273.s1.nabble.com/macro-Redirection-in-exec-UNIX-binary-tp3687463p3687465.html

Great list members,

in this case special thanks goes to Michael Schmid and Johannes Schindelin.

I think this valuable tip is worth being included with the macro
functions manual, no?

The reason is that quite some useful UNIX-Binaries work with stdin or
stdout only.


>Hi Herbie,
>
>there is a trick to do it, using the shell with '-c commandstring'
>e.g.
>   exec("/bin/sh", "-c", "pwd >/tmp/test");
>writes the output of the 'pwd' command to /tmp/test
>
>The -c switch works at least with bash, I am not sure about the
>original Bourne shell.
>
>Michael
>________________________________________________________________
>
>On 27 Jul 2010, at 22:07, Gluender wrote:
>
>>Sorry to bother the list once more...
>>
>>Is it possible to use "redirection" when executing an UNIX-binary
>>from a macro?
>>
>>For example from OSX-Terminal I write
>>
>> MyMac:~ me$ theBinary --output=theFile.png < /pathTo/myData
>>
>>with input file "/pathTo/myData".
>>
>>From an ImageJ macro
>>
>> exec( "theBinary", "--output=theFile.png", "<", "/pathTo/myData" );
>>
>>doesn't do the trick.
>>
>>Is there a way to redirect standard input to an input file with exec( )?
>>
>>Best Herbie



Thanks again to the IJ-heroes of the day and to Wayne for ImageJ !

Best
--

                   Herbie

          ------------------------
          <http://www.gluender.de>