Login  Register

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

Posted by Michael Schmid on Jul 28, 2010; 9:14am
URL: http://imagej.273.s1.nabble.com/macro-Redirection-in-exec-UNIX-binary-tp3687463p3687464.html

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
>
>          ------------------------
>          <http://www.gluender.de>