title: How do I execute shell script from Jenkins groovy script in the parameters option?
body: <p>I want to call a shell script in the Uno-Choice Dynamic Reference Parameter
  and perform some operation (create some files and call some other shell
  scripts from the called shell script) .</p>
  
  <p>As of now I am able to call shell script and cat some files but I am not able
  to create new files  or call another shell script from within this.</p>
  
  <pre><code>def sout = new StringBuffer(), serr = new StringBuffer()
  
  // 1) 
  def proc ='cat /home/path/to/file'.execute()
  //display contents of file
  
  // 2) 
  def proc="sh /home/path/to/shell/script.sh".execute()
  //to call a shell script but the above dosent work if I echo some contents
  //into some file.
  
  proc.consumeProcessOutput(sout, serr)
  proc.waitForOrKill(1000)
  return sout.tokenize()
  </code></pre>
  
  <p>eg:- in <code>script.sh</code> if  I add line </p>
  
  <pre><code>echo "hello world" &gt; test
  </code></pre>
  
  <p>then test file is not created    </p>
  
  <p>for more understanding:</p>
  
  <p><a href="https://stackoverflow.com/questions/159148/groovy-executing-shell-commands">Groovy executing shell commands</a></p>
  
  <p><a href="http://jenkins-ci.361315.n4.nabble.com/Executing-a-shell-python-command-in-Jenkins-Dynamic-Choice-Parameter-Plugin-td4711174.html" rel="nofollow noreferrer">http://jenkins-ci.361315.n4.nabble.com/Executing-a-shell-python-command-in-Jenkins-Dynamic-Choice-Parameter-Plugin-td4711174.html</a></p>