JSch Exec output for error

后端 未结 2 2043
孤街浪徒
孤街浪徒 2021-01-06 16:23

I need to run shell script at a remote machine. I am using JSch to connect to the remote machine and executing the shell script using ChannelExec. I need to kno

2条回答
  •  旧巷少年郎
    2021-01-06 16:58

    Start with the official example for the "exec" channel, do not re-invent the wheel:
    http://www.jcraft.com/jsch/examples/Exec.java.html

    To read the error, read also the error stream using the ChannelExec.getErrStream.

    Or merge the output and error streams into one:
    How to get one stream from error stream and input stream when calling a script using JSCH

提交回复
热议问题