LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   backspace makes a ^H character (https://www.linuxquestions.org/questions/linux-newbie-8/backspace-makes-a-%5Eh-character-4175671214/)

erik2282 03-12-2020 02:31 PM

backspace makes a ^H character
 
At work we have an old database we log into using rxvt terminal with ssh -X. When accessing the system from a Debian 8 machine the backspace key works normal but on my new system with Debian 10 and my Ubuntu 18.04 laptop, the backspace keys prints a ^H on the screen. To delete a character I have press Ctrl and h keys. How can I make this work with Debian 10.
I've been reading about this but honestly i feel like im just going into a rabbit hole. I don't know if i need to change something on the server side or my desktop. This is also happening to my coworkers that just moved to Debian 10.
Thanks.

ehartman 03-12-2020 03:06 PM

Quote:

Originally Posted by erik2282 (Post 6099872)
To delete a character I have press Ctrl and h keys. How can I make this work with Debian 10.

Execute the command
Quote:

stty erase "^h" (that is a ^ char followed by a h letter)
from your .bash_profile or such (if you're using bash on that system, of course, I think Debian often uses dash, if so, try .profile instead).
It is a well-known problem that some terminal emulators use "^?" and others "^h" (in both cases that is a ^ followed by the next char).

agillator 03-12-2020 03:16 PM

It is probably a matter of the terminal emulator you are using. You say the database is old so it may be expecting something older than what you are using. See if you have xterm installed. If so, try it. If not, try installing it and using it. There are a number of terminal emulators out there so try different ones, and check the configuration files to see what they use for the backspace. At a guess I would say your database computer is expecting a VT100 terminal. If you check the configuration file you will probably find that backspace sends an ascii-8 character or an ascii-128 character. Whichever it sends, change it to the other and see what happens.

erik2282 03-12-2020 03:51 PM

Quote:

Originally Posted by ehartman (Post 6099886)
Execute the commandfrom your .bash_profile or such (if you're using bash on that system, of course, I think Debian often uses dash, if so, try .profile instead).
It is a well-known problem that some terminal emulators use "^?" and others "^h" (in both cases that is a ^ followed by the next char).

Just to make it clear, what you're saying is in my .bashrc file in my debian desktop, add that line in there and then try remote to the the database?

erik2282 03-12-2020 04:03 PM

Quote:

Originally Posted by agillator (Post 6099890)
See if you have xterm installed. If so, try it. If not, try installing it and using it.

After installing it, it still didn't work.


Quote:

There are a number of terminal emulators out there so try different ones, and check the configuration files to see what they use for the backspace. At a guess I would say your database computer is expecting a VT100 terminal. If you check the configuration file you will probably find that backspace sends an ascii-8 character or an ascii-128 character. Whichever it sends, change it to the other and see what happens.
This is the contents of the file i use to launch it from my desktop. I have it as a custom app on my toolbar.
Code:

my-debian-desktop~$ cat /path/to/launcher
stty erase ^?
stty intr ^c

BACKGROUND=black
FOREGROUND=grey
FONT=12x24

rxvt -vb --backspacekey "^H" -sl 400 -fn $FONT -fg $FOREGROUND -bg $BACKGROUND -e '/Launchers/SSH_database' -tn newrxvt

Code:

my-debian-desktop~$ cat /Launchers/SSH_database
ssh -X database

EDIT: so after playing around with the file I made it look like this:

Code:

#stty erase ^?
#stty intr ^c

BACKGROUND=black
FOREGROUND=grey
FONT=12x24

#rxvt -vb --backspacekey "^H" -sl 400 -fn $FONT -fg $FOREGROUND -bg $BACKGROUND -e '/Launchers/SSH_database' -tn newrxvt
rxvt -vb -sl 400 -fn $FONT -fg $FOREGROUND -bg $BACKGROUND -e '/Launchers/SSH_database' -tn newrxvt

and now the backspace doesnt do the characters anymore, the backpace just doesnt do anything. Ctrl + H still works for backspacing.

ehartman 03-12-2020 04:44 PM

Quote:

Originally Posted by erik2282 (Post 6099897)
Just to make it clear, what you're saying is in my .bashrc file

No, although distro's differ, the .bashrc is normally only executed for a NON-login shell, you will need the .profile or .bash_profile one as that file is for a login shell, which is where a stty should be executed.

And note (from another of your messages):
Quote:

stty erase ^?
rxvt -vb --backspacekey "^H"
Here you set erase to DELETE (127), but you tell rxvt to expect a backspace (8). Probably if you would have left out the --backspacekey option it would have worked as DELETE is the default for rxvt.

erik2282 03-12-2020 05:03 PM

Quote:

Originally Posted by ehartman (Post 6099912)
Here you set erase to DELETE (127), but you tell rxvt to expect a backspace (8). Probably if you would have left out the --backspacekey option it would have worked as DELETE is the default for rxvt.

I tried that with same result: when i hit backspace, it doesn't print the characters, backspace just doesn't do anything.

erik2282 03-13-2020 08:35 AM

Quote:

Originally Posted by ehartman (Post 6099912)
No, although distro's differ, the .bashrc is normally only executed for a NON-login shell, you will need the .profile or .bash_profile one as that file is for a login shell, which is where a stty should be executed.

Where would I put that in the .profile file? Yes, you're right, I dont have a .bash_profile.
Code:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi


BW-userx 03-13-2020 09:02 AM

doesn't the inputrc and .inputrc file deal with keyboard stuff like this? so if the 'shortcut' key is wrong in its deffs then it acts up like that?

https://unix.stackexchange.com/quest...dline-commands

rtmistler 03-13-2020 09:16 AM

Quote:

Originally Posted by erik2282 (Post 6099872)
At work we have an old database we log into using rxvt terminal with ssh -X. When accessing the system from a Debian 8 machine the backspace key works normal but on my new system with Debian 10 and my Ubuntu 18.04 laptop, the backspace keys prints a ^H on the screen. To delete a character I have press Ctrl and h keys. How can I make this work with Debian 10.
I've been reading about this but honestly i feel like im just going into a rabbit hole. I don't know if i need to change something on the server side or my desktop. This is also happening to my coworkers that just moved to Debian 10.
Thanks.

Quote:

Originally Posted by agillator (Post 6099890)
It is probably a matter of the terminal emulator you are using. You say the database is old so it may be expecting something older than what you are using. See if you have xterm installed. If so, try it. If not, try installing it and using it. There are a number of terminal emulators out there so try different ones, and check the configuration files to see what they use for the backspace. At a guess I would say your database computer is expecting a VT100 terminal. If you check the configuration file you will probably find that backspace sends an ascii-8 character or an ascii-128 character. Whichever it sends, change it to the other and see what happens.

agillator's point was what I was thinking.

And given that it works one way in Debian 8 and another way in Debian 10 and Ubuntu 18.04, why can't you grab the stty attributes and compare?

erik2282 03-17-2020 02:35 PM

Quote:

Originally Posted by rtmistler (Post 6100080)
grab the stty attributes and compare?

Hello, I'm not sure what stty attributes are. Where do I look for them? Thanks.

erik2282 03-20-2020 04:32 PM

any ideas?

ehartman 03-20-2020 05:58 PM

Quote:

Originally Posted by erik2282 (Post 6101650)
Hello, I'm not sure what stty attributes are. Where do I look for them? Thanks.

After you logged in, on either system, do 'stty' and look at the "erase" line in its output (in my system it is the second line). If it is NOT 'erase = ^H;' this terminal (emulator) is NOT using backspace as the erase character, so you'll have to change it in your .profile by adding a line
Quote:

stty erase '^h'
Note that to be sure that is not a "real backspace", but a "^" character followed by an h

erik2282 03-20-2020 06:11 PM

Looks the same in both systems.

Code:

erik@topaz:~$ stty                                                       
speed 38400 baud; line = 0;
-brkint -imaxbel
erik@topaz:~$ ssh tethra                                                 
erik@tethra's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Mar 20 16:15:25 2020 from topaz.aasteel.net
erik@tethra:~$ stty
speed 38400 baud; line = 0;
-brkint -imaxbel
erik@tethra:~$


ehartman 03-20-2020 11:35 PM

Quote:

Originally Posted by erik2282 (Post 6102750)
Looks the same in both systems.

Code:

erik@topaz:~$ stty                                                       
speed 38400 baud; line = 0;
-brkint -imaxbel


OK, your version of stty doesn't seem to give the "erase" line in the default case, so then use "stty -a" (return ALL stty settings) and look in the output for the "erase =" setting. You can (mostly) ignore all of the other settings given, they're not that important for Linux consoles and/or terminal emulators, only for real terminals, connected to i.e. a serial line/port.
The stty was originally written for those real terminals on Unix systems
Quote:

stty - change and print terminal line settings
and a lot of the settings are only for those serial lines (or the terminals, connected TO them). Even the speed is a fake one as "baud" is the serial transfer rate in bits per second.


All times are GMT -5. The time now is 10:17 AM.