commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject Re: Re: [exec] command with single quotes and pipe
Date Fri, 20 Dec 2013 17:07:39 GMT
On 20 December 2013 15:18, ioannis latousakis <> 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:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message