Tuesday, July 10, 2007

Backspace in Telnet

ช่วงอาทิตย์นี้ได้มีโอกาสได้เล่น IBM AIX ที่บริษัท
ตัวเครื่องนั้นถูกตั้งไว้ชั้นล่าง เวลาเข้าไปใช้งานจึงต้องใช้งานผ่าน telnet (ซึ่งจริงๆแล้วยังนึกสงสัยอยู่ว่าทำไมมันถึงไม่ใช้ ssh)

ระหว่างที่ใช้ telnet นั้นเจอปัญหารบกวนใจเล็กน้อย คือเมื่อกดปุ่ม backspace พบว่ามีสัญลักษณ์ ^? ออกมาแทนการลบตัวอักษร

เราสามารถแก้ไขได้โดยการใช้คำสั่ง stty ในการตั้งปุ่มที่จะใช้เป็นคำสั่งที่ต้องการ เช่นตั้ง ^? ให้เป็นคำสั่ง erase ซึ่งทำได้ดังนี้
stty erase ^?

1 comment:

Unknown said...

Hi, John. I found your new blog. Sorry, but I'm too lazy to type Thai.

The rule of thumb is type "stty erase " and then your backspace key. Sometimes it's ^? or sometimes ^H. A fun trick to do to somebody else's terminal is "stty erase \ " (i.e. set space bar to become backspace).

Remember, to escape any "special" key, press ^V and then the normal key. So to get a space after you do the nasty command above, you have to press ^V<space>.

About ^V, a nice trick to reset the screen is "echo " then type ^V, then Alt-C (or Esc, 'C') then press enter. Echo will print ASCII code 03, which is a standard signal for the TTY (xterm, konsole, etc.) to reset itself. This works on systems that don't have ncurses ("reset" and "tset" commands), like Unix.