Removing shell stuff (like prompts) from command output in JSch

后端 未结 1 710
时光说笑
时光说笑 2020-12-06 23:41

I have successfully SSH\'ed into a node, sent the input, and retrieved the output. After inputting a line, the line is printed to the console, followed by a blank line, and

相关标签:
1条回答
  • 2020-12-07 00:37

    These are all consequences of the "shell" channel.

    You run an interactive session with all the fancy stuff that human users like.

    The "shell" channel is not intended for automation.

    You may remove some of these by calling channel.setPty(false) before channel.connect().


    Though you better use the "exec" channel.

    This may work:

    ( echo username & echo password & echo hostname ) | command
    

    Related questions:

    • Remove of unwanted characters when I am using JSch to run command
    • Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine?
    0 讨论(0)
提交回复
热议问题