You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by ioannis latousakis <la...@gmail.com> on 2013/12/20 16:18:06 UTC

Re: Re: [exec] command with single quotes and pipe

I found a way to make this work with apache exec by doing the following:

        String [] cmd ={"-c","convert -size 140x80 xc:none -fill grey -gravity NorthWest -draw \"text 10,10 'Copyright'\" -gravity SouthEast -draw \"text 5,15 'Copyright'\" miff:- | composite -tile - /Users/latu/Pictures/desert.jpg  /Users/latu/Pictures/desertCP.jpg"};
        CommandLine convert_cmd = new CommandLine("/bin/sh");
        convert_cmd.addArguments( cmd,false );
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Re: [exec] command with single quotes and pipe

Posted by sebb <se...@gmail.com>.
On 20 December 2013 15:18, ioannis latousakis <la...@gmail.com> wrote:
> I found a way to make this work with apache exec by doing the following:
>
>         String [] cmd ={"-c","convert -size 140x80 xc:none -fill grey -gravity NorthWest -draw \"text 10,10 'Copyright'\" -gravity SouthEast -draw \"text 5,15 'Copyright'\" miff:- | composite -tile - /Users/latu/Pictures/desert.jpg  /Users/latu/Pictures/desertCP.jpg"};
>         CommandLine convert_cmd = new CommandLine("/bin/sh");

Obviously, that only works if the OS has got a shell that supports this.

You are now running everything through the shell, instead of running
the commands directly.
This is not generally recommended as it is relatively fragile and more
prone to security issues.

The recommended approach is to run each part of the pipe separately,
and tie the output of the first command to the input of the second.

>         convert_cmd.addArguments( cmd,false );
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org