What is the difference between the 'shell' channel and the 'exec' channel in JSch

前端 未结 4 1900
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 05:36

I want to be able to send many consecutive command represented as strings within a Java application to a SSH server for execution. Should I use:

Channel cha         


        
4条回答
  •  隐瞒了意图╮
    2020-11-29 06:20

    With shell channel the shell (on unix it's sh or bash or something like that, on Windows it's usually cmd.exe) is started and console is created (the same you see on the screen if you run them locally). You have a prompt which you can parse or use for detection of completion of command.

    With command channel a shell instance is started for each command (actually the channel is opened for each command) and a command is passed as a parameter for the shell (on Windows it would look like "cmd.exe /c ".

    It's easier to use command channel cause you don't need to deal with command prompt.

提交回复
热议问题