Android 无法使用groovy脚本执行plink命令

Android 无法使用groovy脚本执行plink命令,android,groovy,ssh,adb,plink,Android,Groovy,Ssh,Adb,Plink,我在windows上运行的plink命令遇到了问题。下面是我为删除远程android设备的iptable而发出的命令 plink.exe-v-sshrauser@HOSTNAME-pw PASSWORD iptables-D INPUT-p tcp-m tcp-dport 5555-j DROP 我可以从命令提示符手动执行该命令,但当我从groovy脚本以bat文件的形式执行该命令时,它会抛出一个错误。我正在与您共享这两个命令 Groovy脚本 // enable ADB commandsLis

我在windows上运行的plink命令遇到了问题。下面是我为删除远程android设备的iptable而发出的命令

plink.exe-v-sshrauser@HOSTNAME-pw PASSWORD iptables-D INPUT-p tcp-m tcp-dport 5555-j DROP

我可以从命令提示符手动执行该命令,但当我从groovy脚本以bat文件的形式执行该命令时,它会抛出一个错误。我正在与您共享这两个命令

Groovy脚本

// enable ADB
commandsList.add(""
    "enable-adb.bat "
    "" + deviceip)
// run adb commands
commandsList.each {
        def command = pathtoadb + it
        log.info command
        def proc = command.execute()
        proc.waitFor() // Wait for the command to finish
        // Obtain status and output
        log.info "return code: ${ proc.exitValue()}" // "0" is success
        //log.info "stderr: ${proc.err.text}"
        log.info "stdout: ${proc.in.text}" // *out* from the external program is *in* for groovy
        def error = proc.err.text;
        // if the output contains "Bad rule" that means ADB is already enabled and we don't want the test to fail
        if (!error.contains("Bad rule")) {
            log.info "  _______  There was a problem connecting to your device using SSH. Check if remote access is enabled on your device"
            log.info("ERROR:   " + error)
        } else {
            log.info "  _______  return code is 1 because ADB was already enabled - this is not a failure"
            log.info("        ********    ADB has been enabled on device -->  " + deviceip)
        }
异常消息

Server version: SSH-2.0-OpenSSH_5.9
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.62
Doing Diffie-Hellman group exchange
Server unexpectedly closed network connection
FATAL ERROR: Server unexpectedly closed network connection

首先,我建议你升级到Plink/PuTTY的最新版本。请说明否决投票的原因。我没有否决你的问题。但由于你没有采纳我的建议,并且仍然在使用7年前的安全软件,你应该得到否决票。好吧!首先感谢你的建议。我正在使用一些新版本的plink。只是想对它有更多的想法。:)我还想再次提到,同一个命令在命令行中运行良好。所以我不太希望这是plink版本的问题。请确保groovy执行的plink版本与您在命令行中执行的版本相同。您可能有两份副本。首先,我建议您升级到最新版本的Plink/PuTTY。请说明否决投票的原因。我没有否决您的问题。但由于你没有采纳我的建议,并且仍然在使用7年前的安全软件,你应该得到否决票。好吧!首先感谢你的建议。我正在使用一些新版本的plink。只是想对它有更多的想法。:)我还想再次提到,同一个命令在命令行中运行良好。所以我不太希望这是plink版本的问题。请确保groovy执行的plink版本与您在命令行中执行的版本相同。你可以有两份。