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..
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..
The >
is a shell operator and should be run within a shell. Try this, it may work:
sh -c 'bash copy.txt > copy.log'
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.
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