tags:

views:

38

answers:

1

How to run this command in groovy :

/home/srinath/junk/sync.sh > /home/srinath/junk/copy.log

This is working when tried on terminal . but fails when used execute in groovy

Could any one please help me on this .

thanks in advance
sri..

+1  A: 

Shell based redirection and piping doesn't work from inside the JVM without a bit of data handling

For this example, you should be able to do:

new File( '/home/srinath/junk/copy.log' ).write( '/home/srinath/junk/sync.sh'.execute().text )
tim_yates
hi tim, when executed i was getting this issue Caught: java.lang.NullPointerException: Cannot invoke method execute() on null object at test.run(test.groovy:11). any thing going wrong ?. thanks
Srinath
you can't be running that line of code... no way can that be null as far as I can see
tim_yates
@tim, example working good. thanks a lot
Srinath