[ 
https://issues.apache.org/jira/browse/SSHD-1064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17185048#comment-17185048
 ] 

Björn Kautler commented on SSHD-1064:
-------------------------------------

Uhm, no, the missing exit status is complained about first and then the err is 
not displayed, as I said.

When I tested with this, err was displayed properly and for the second command 
exit signal was {{HUP}} and exit status {{null}}:
{code:java}
SshClient.setUpDefaultClient().use { ssh ->
   ssh.start()
   ssh.connect("user", "server.company.com", 22).verify().session.use { session 
->
      session.addPasswordIdentity("p@ssw0rd")
      session.auth().verify()
      session.createExecChannel("id").use { channel ->
         val out = ByteArrayOutputStream()
         val err = ByteArrayOutputStream()
         channel.out = out
         channel.err = err
         channel.open().verify()
         channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), -1)
         println("out:\n$out")
         println("err:\n$err")
         println("exitSignal: ${channel.exitSignal}")
         println("exitStatus: ${channel.exitStatus}")
      }
      session.createExecChannel("ps aux").use { channel ->
         val out = ByteArrayOutputStream()
         val err = ByteArrayOutputStream()
         channel.out = out
         channel.err = err
         channel.open().verify()
         channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), -1)
         println("out:\n$out")
         println("err:\n$err")
         println("exitSignal: ${channel.exitSignal}")
         println("exitStatus: ${channel.exitStatus}")
      }
   }
}
 {code}

> Mutliple commands in one  session do not work
> ---------------------------------------------
>
>                 Key: SSHD-1064
>                 URL: https://issues.apache.org/jira/browse/SSHD-1064
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.5.1
>            Reporter: Björn Kautler
>            Assignee: Lyor Goldstein
>            Priority: Minor
>
> I tried to do this:
> {code:java}
> SshClient.setUpDefaultSimpleClient().use { ssh ->
>    ssh.sessionLogin("server.company.com", "user", "p@ssw0rd").use { session ->
>       println(session.executeRemoteCommand("id"))
>       println(session.executeRemoteCommand("ps aux"))
>    }
> }
> {code}
> (If you are not familiar with the syntax, it is Kotlin. The {{use}} works 
> like a try-with-resources, I think the rest should be pretty obvious)
> This is supposed to work, isn't it?
> Yet it does not work.
> The first command works fine and then for the second command I get 
> {{java.rmi.RemoteException: No exit status returned for command=ps aux}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to