I’m unable to use Groovy to execute a shell command that has backticks. A simplified example:
println "echo `date`".execute().text
I searched around and tried to figure out how to escape them somehow, but without luck.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What happens if you try:
My guess would be that with
java’s
Runtime#exec(String)would be used underneath, if you were callingexecute()on a String. In which case, this simply tokenizes the string and executes the programechowith the argumentor
but that’s shell (bash) syntax, and must be executed via bash.