tags:

views:

64

answers:

3

I need to run this command in Groovy when click on button

bash copy.txt > copy.log

I tried with execute but not worked out .

Could any one please help me

thanks in advance sri..

A: 

The > is a shell operator and should be run within a shell. Try this, it may work:

sh -c 'bash copy.txt > copy.log'
Delan Azabani
Hi Delan , I tried like this but no luck . i didnt find copy.log in my folder .def test = "sh -c 'bash /home/srinath/Desktop/copy.txt > copy.log'"test.execute(). Thanks
srinath
A: 

In bash you usally do

cat copy.txt > copy.log

Unless you are assume that copy.txt is a shell script. But I guess not according to the extension you give.

mathk
A: 

I presume that you are trying to copy the file copy.txt to copy.log in the same folder. There are several 'pure' Groovy ways to do this but you can do it using native calls on linux as follows.

Example: ['/bin/sh', '-c', 'cat copy.txt > copy.log'].execute().consumeProcessOutput(System.out, System.err)

The Groovy way: new File('copy.log') << new File('copy.txt').text

xlson