【问题标题】:How to figure out if a command executed using JSch in Java has successfully completed?如何判断在 Java 中使用 JSch 执行的命令是否已成功完成?
【发布时间】:2021-06-06 23:38:53
【问题描述】:

在使用 Java 中的 JSch 库发送下一个命令之前,我无法确定命令是否已完成执行。

代码sn-p

// Opens a new channel of type 'exec'
Channel channel = sesConnection.openChannel("exec"); 
// sets the command to be executed
((ChannelExec) channel).setCommand(command); 
// Gets an input stream for this channel
InputStream commandOutput = channel.getInputStream(); 
channel.connect();

【问题讨论】:

    标签: java ssh jsch


    【解决方案1】:

    执行命令时,您可以使用两个来源来确定命令是否失败:

    有关如何阅读两者的示例,请参阅How to read JSch command output?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多