Re: Problem running find execute has error

2019-06-11 Thread Paul King
Most folks with anything but the simplest args find the String[] variant of
execute to be easier to use than the String variant.


On Wed, Jun 12, 2019 at 4:05 AM Sverre Moe  wrote:

> Groovy is doing something strange with my execute command.
> Or perhaps something wrong with my code I cannot see.
>
> vim find.groovy
> def sout = new StringBuilder(), serr = new StringBuilder()
> def proc = "find RPMS -regex '.*/package-name-[0-9.]+-.\\.x86_64\\.rpm'
> -exec cp -v {} . \\;".execute()
> proc.consumeProcessOutput(sout, serr)
> proc.waitForOrKill(1000)
> println "out> $sout"
> println "err> $serr"
>
> Create the directory and files for testing the find.groovy
> mkdir RPMS
> touch RPMS/package-name-1.0.0-1.x86_64.rpm
> touch RPMS/package-name-devel-1.0.0-1.noarch.rpm
>
> The output from running the find.groovy seems to suggest the find command
> is wrong.
> groovy find.groovy
> err> find: argument for «-exec» is missing
>
> But running it in bash works just fine:
> find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} .
> \;
> 'RPMS/package-name-1.0.0-1.x86_64.rpm' ->
> './package-name-1.0.0-1.x86_64.rpm'
>
> I can reproduce the error in Bash with an additional slash at the end.
> find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} .
> \\;
> find: argument for «-exec» is missing
>
>
> /Sverre
>


Re: Problem running find execute has error

2019-06-11 Thread Remko Popma
Maybe in Groovy you don’t need to escape the semicolon. 
The semicolon has special meaning in the shell so there it does need to be 
escaped, but in the Groovy command you can just pass it as the delimiter arg to 
-exec. 

Remko.

(Shameless plug) Every java main() method deserves http://picocli.info

> On Jun 12, 2019, at 3:05, Sverre Moe  wrote:
> 
> Groovy is doing something strange with my execute command.
> Or perhaps something wrong with my code I cannot see.
> 
> vim find.groovy
> def sout = new StringBuilder(), serr = new StringBuilder()  
> def proc = "find RPMS -regex '.*/package-name-[0-9.]+-.\\.x86_64\\.rpm' -exec 
> cp -v {} . \\;".execute()
> proc.consumeProcessOutput(sout, serr)  
> proc.waitForOrKill(1000)  
> println "out> $sout"  
> println "err> $serr"
> 
> Create the directory and files for testing the find.groovy
> mkdir RPMS
> touch RPMS/package-name-1.0.0-1.x86_64.rpm
> touch RPMS/package-name-devel-1.0.0-1.noarch.rpm
> 
> The output from running the find.groovy seems to suggest the find command is 
> wrong.
> groovy find.groovy
> err> find: argument for «-exec» is missing
> 
> But running it in bash works just fine:
> find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} . \;
> 'RPMS/package-name-1.0.0-1.x86_64.rpm' -> './package-name-1.0.0-1.x86_64.rpm'
> 
> I can reproduce the error in Bash with an additional slash at the end.
> find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} . \\;
> find: argument for «-exec» is missing
> 
> 
> /Sverre


Problem running find execute has error

2019-06-11 Thread Sverre Moe
Groovy is doing something strange with my execute command.
Or perhaps something wrong with my code I cannot see.

vim find.groovy
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = "find RPMS -regex '.*/package-name-[0-9.]+-.\\.x86_64\\.rpm'
-exec cp -v {} . \\;".execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout"
println "err> $serr"

Create the directory and files for testing the find.groovy
mkdir RPMS
touch RPMS/package-name-1.0.0-1.x86_64.rpm
touch RPMS/package-name-devel-1.0.0-1.noarch.rpm

The output from running the find.groovy seems to suggest the find command
is wrong.
groovy find.groovy
err> find: argument for «-exec» is missing

But running it in bash works just fine:
find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} .
\;
'RPMS/package-name-1.0.0-1.x86_64.rpm' ->
'./package-name-1.0.0-1.x86_64.rpm'

I can reproduce the error in Bash with an additional slash at the end.
find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} .
\\;
find: argument for «-exec» is missing


/Sverre