jassh icon indicating copy to clipboard operation
jassh copied to clipboard

sudo hang

Open q1208c opened this issue 6 months ago • 1 comments

when try use 'become' run command with sudo, then program hang without any output or error. below is the code(some function).

    def runWithSudo(cmdString: String): (Boolean, String) = {
        log.info(
            s"run command '${cmdString}' with sudo on '${this.user}@${this.host}:${this.port}'"
            )
        val sshOptions         = this.sshOption()
        var runState : Boolean = false
        var runResult: String  = ""
        try {
            SSH.once(sshOptions) { ssh => {
                val (r1, r2) = ssh.shell { sh =>
                    sh.become("root") -> sh.execute(cmdString)
                }
                runState = r1
                runResult = r2
            }
            }
        } catch {
            case ex: Exception => log.error("SSHHost.runWithSudo", ex)
        }
        (runState, runResult)
    }

The SSHOption is only set user, host, port, all other is default.

I think there something wrong, what I can do? Thanks.

q1208c avatar Aug 20 '24 08:08 q1208c