LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-12-2020, 02:31 PM   #1
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Rep: Reputation: 229Reputation: 229Reputation: 229
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.

Last edited by erik2282; 03-12-2020 at 02:33 PM.
 
Old 03-12-2020, 03:06 PM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by erik2282 View Post
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).
 
Old 03-12-2020, 03:16 PM   #3
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
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.
 
Old 03-12-2020, 03:51 PM   #4
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by ehartman View Post
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?
 
Old 03-12-2020, 04:03 PM   #5
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by agillator View Post
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.

Last edited by erik2282; 03-12-2020 at 04:13 PM.
 
Old 03-12-2020, 04:44 PM   #6
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by erik2282 View Post
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.
 
Old 03-12-2020, 05:03 PM   #7
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by ehartman View Post
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.
 
Old 03-13-2020, 08:35 AM   #8
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by ehartman View Post
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

Last edited by erik2282; 03-13-2020 at 08:36 AM.
 
Old 03-13-2020, 09:02 AM   #9
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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
 
Old 03-13-2020, 09:16 AM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by erik2282 View Post
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 View Post
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?
 
Old 03-17-2020, 02:35 PM   #11
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by rtmistler View Post
grab the stty attributes and compare?
Hello, I'm not sure what stty attributes are. Where do I look for them? Thanks.
 
Old 03-20-2020, 04:32 PM   #12
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
any ideas?
 
Old 03-20-2020, 05:58 PM   #13
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by erik2282 View Post
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
 
Old 03-20-2020, 06:11 PM   #14
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Original Poster
Rep: Reputation: 229Reputation: 229Reputation: 229
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:~$

Last edited by erik2282; 03-20-2020 at 07:37 PM.
 
Old 03-20-2020, 11:35 PM   #15
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by erik2282 View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backspace Key deletes section not single character onthefritz Red Hat 4 06-24-2010 01:43 PM
Bash scripting: parsing a text file character-by-character Completely Clueless Programming 13 08-12-2009 09:07 AM
trying to use GNU screen. backspace makes screen flash. twelvenine Linux - Software 5 08-07-2009 08:37 PM
To know the function on checking whether a character is ascii or unicode character. murugesan Programming 2 01-23-2009 01:07 PM
about wide character and multiple byte character George2 Programming 5 05-23-2006 01:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration