Through MobaXterm's SSH feature, I'm running a Java application on a remote Linux server. A problem arises when I attempt to type into the terminal (to process user input requests via Scanner) and any logging occurs. The text I'm typing is automatically pushed into the logging section when any print statements happen.
Clarifying example:
I manually type "MY_INPUT_TO_SET_SOME_VARIABLE 50" into the console (and never press ENTER).
Some logging on the server occurs and automatically "sends" the manually typed "MY_INPUT_TO_SET_SOME_VARIABLE 50" into the display area.
(above, you can see 50 is appended to 09:08 when I never pressed enter).
The desired behavior is to allow the power user to simply type text in the terminal's text area (or somewhere reasonable) until the ENTER key is pressed. The text in the terminal's text area should not automatically be pushed upon logged or printed statements. I looked in terminal settings and wasn't able to find anything to modify this behavior.
1 Answers
Answers 1
As others already mentioned in the comment section there is not much you can do about that behaviour.
However usually you don't want logging on the tty you're working with.
If you have root rights on the system you connect to try to suppress the log messages on the console and redirect them to a logfile unless there is a good reason not to do so. Since it depends who is sending the messages the method to do so differs.
Another possibility is to start a screen session in your terminal to open a new tty. For ease of use I would connect directly into a screen session:
ssh -t user@server /usr/bin/screen
If you create a .screenrc file in the home directory of the user you connect to, put
startup_message off
in it if you don't like the screen start message. You can even start your console app with it, so that the screen session ends when you stop your app.
ssh -t user@server /usr/bin/screen your_start_command_here
Screen has more features like naming a session, reattaching to a session etc. See the manual for further details.
(The screen solution apparently only works if the log messages on the screen are not produced by your application. In that case configure your logger that it does not log to stdout)
0 comments:
Post a Comment