运行sudo命令的Gradle任务sudo:不存在tty且未指定askpass程序

时间:2018-09-10 16:42:13

标签: gradle zsh sudo iterm2

当我尝试在gradle任务中运行sudo命令时,它向我显示以下错误,并且不要求我提供sudo密码:

➜ myProject ./gradlew startSudoScript

> Task :startSudoScript
sudo: no tty present and no askpass program specified


BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

这是任务的样子:

task startSudoScript(description: "Starts sudo script") {
    doLast {
        logger.info("script is excuting")

        def procScript = exec {
            ignoreExitValue = true
            executable = "sudo"
            args = ["-E", "script.sh"]
        }
    }
}
  • macosx 10.12.6
  • 4.4.1级
  • iTerm2内部版本3.2.0
  • zsh 5.3.1(x86_64-apple-darwin16.3.0)

0 个答案:

没有答案