Frage

I have the following command in my groovy script

   println "cmd /c remove_files.bat".execute().text

Groovy runs the BAT file - remove_files.bat , but the BAT file stop on the question:

  do you really want to remove them [y/n]?

this question is the single question that I need to answer in order to continue

so

Anyone have a smart idea what need to add/change in the execute groovy command in order to answer this question automatically ?

remove_files.bat file

  @echo off


  ECHO all files will remove from C:\backup directory.

  set /p delBuild=Delete do you really want to remove them [y/n]?

   .
   .
   .
   .
   .
War es hilfreich?

Lösung

Can you try:

def proc = [ 'cmd', '/c', 'remove_files.bat' ].execute()
proc << 'y'

StringBuilder output = new StringBuilder()
proc.waitForProcessOutput(output, output)
println output.toString()

Not sure if it will work, I don't have a Windows machine to test it on :-(

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top