[英]groovy script + run CLI command + WIN XP
我的groovy腳本中有以下命令
println "cmd /c remove_files.bat".execute().text
Groovy運行BAT文件-remove_files.bat ,但是BAT文件停止在以下問題上:
do you really want to remove them [y/n]?
這個問題是我需要回答以繼續的唯一問題
所以
任何人都有一個聰明的主意,為了自動回答這個問題,需要在execute groovy命令中添加/更改什么?
remove_files.bat文件
@echo off
ECHO all files will remove from C:\backup directory.
set /p delBuild=Delete do you really want to remove them [y/n]?
.
.
.
.
.
你能試一下嗎:
def proc = [ 'cmd', '/c', 'remove_files.bat' ].execute()
proc << 'y'
StringBuilder output = new StringBuilder()
proc.waitForProcessOutput(output, output)
println output.toString()
不知道它是否可以工作,我沒有Windows機器可以在:-(
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.