Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a shell script from a Groovy/Grails Application

Tags:

grails

groovy

How can I call a native shell script from a Groovy / Grails Application?

The shell script resides on the same machine.

like image 982
Daniel Kreiseder Avatar asked Oct 02 '09 08:10

Daniel Kreiseder


2 Answers

Put the name (preferably with an absolute path) and the arguments in a list and call execute():

['/path/to/script', 'arg1', 'arg2'].execute()

The Groovy documentation suggests to use a simple string instead. I advise against that because it can cause all kinds of problems with special characters, white space in arguments, etc.

like image 103
Aaron Digulla Avatar answered Nov 07 '22 01:11

Aaron Digulla


You can use the Groosh module (link)

like image 45
Alexander Egger Avatar answered Nov 06 '22 23:11

Alexander Egger