Note: I log into a device, not a computer, so I login to configuration mode (instead of non configuration mode).
I am using JSch library in Java, to login with an SS
By default the JSch does not request PTY (pseudo-terminal).
That can cause some commands to behave differently than in an interactive SSH terminal.
You can override this using the ChannelSession.setPty.
If the above does not help, see also similar questions: