Re: Command Line Editing - Please advise! (277 Views)
Reply
Occasional Contributor
Sam1586
Posts: 6
Registered: ‎07-27-2013
Message 1 of 7 (315 Views)

Command Line Editing - Please advise!

Hi

 

 

I'm pretty new to the HP-UX. I cannot make the backspace and edit if something goes wrong. I understand there is no Bash in HP-UX, however is there any options available.

 

Thank you

Sam

Please use plain text.
Respected Contributor
P Arumugavel
Posts: 328
Registered: ‎02-16-2010
Message 2 of 7 (310 Views)

Re: Command Line Editing - Please advise!

Hi,

 

The bash shell is not available in HP-UX by default. However you can install it and get the bash functionality.

 

It is available in folloing link.

 

http://hpux.connect.org.uk/hppd/hpux/Shells/bash-4.2.010/

 

If you need the bash shell only for backspace function, then you set the terminal as below.

if you want it to be permanently, edit your .profile file.

 

#stty erase ^?

 

Rgds...

 

Please use plain text.
Occasional Contributor
Sam1586
Posts: 6
Registered: ‎07-27-2013
Message 3 of 7 (296 Views)

Re: Command Line Editing - Please advise!

Thanks for your quick reply. I did tried as said above, but throwing some errory. Please advise. Thanks in advance. 

 

# stty erase^?
unknown mode: erase^?

Please use plain text.
Honored Contributor
Patrick Wallek
Posts: 13,736
Registered: ‎06-21-2000
Message 4 of 7 (292 Views)

Re: Command Line Editing - Please advise!

There's a space between the 'erase' and the '^?'.  To get the '^?' character just hit the backspace key after entering 'stty erase '.  The '^?' should echo to the screen.  Then you can hit enter.

 

So:

 

# stty erase <hit backspace key here> 

 

 

Please use plain text.
Acclaimed Contributor
Torsten.
Posts: 23,216
Registered: ‎10-02-2001
Message 5 of 7 (288 Views)

Re: Command Line Editing - Please advise!

Default command line editing is just like using vi.

As a hp-ux (or unix in general) user to should know or learn some basics.




Hope this helps!
Regards
Torsten.

__________________________________________________

There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________

No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! star in the left column!   
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,898
Registered: ‎03-06-2006
Message 6 of 7 (282 Views)

Re: Command Line Editing - stty

>#stty erase ^?

 

This depends on what your terminal emulator sends.  I want the backspace key and control-H to do the same thing so I have to use: stty erase ^h

 

>To get the '^?' character

 

You can also type this as two separate chars or the DEL char.

 

>Default command line editing is just like using vi.

 

You can confirm this in a real shell by doing:

$ set -o

And check if vi or emacs is set.

Please use plain text.
Honored Contributor
Bill Hassell
Posts: 14,201
Registered: ‎05-29-2000
Message 7 of 7 (277 Views)

Re: Command Line Editing - Please advise!

[ Edited ]

I'll take a guess that you are using PuTTY as your terminal emulator. This very popular (and free) program has one very annoying default: the backspace key is mappopen the ed to the DEL (delete) key, *not* the backspace key. So when you use the backspace key, you'll see ^? on the screen which is the shell's way of showing you this invisible character. To change your emulator to use the backspace key (for PuTTY), open the Configuration window and select:

 

Terminal -> Keyboard

 

and change the Backspace key from Control-? to Control-H (which is the backspace key. Be sure to save this new setting. 

 

Another possibility is that your TERM value has been set to "vt100" and unfortunately, the terminfo database defined the ERASE key as Delete. This can be seen with the command: untic vt100, and look for the capname "kbs" which refers to the keyboard backspace character. For (IMHO) sane settings, look at untic hp and you'll see kbs=\b which means that the backspace (action to erase the previous character) is backspace and not 177 which is the Delete key.

 

To fix the default TERM value, add this line to your profile:

 

stty erase"^H"

 

Set your .profile and alsoterminal emulator.

 

Why is backspace mapped to the Delete key? Most likely the original designers for PuTTY and terminfo settings were OpenVMS or DEC OS users where the erasing of a character meant pressing the Delete key. Just a guess...

 

Once you are able edit your lines with the backspace key, the next (non-intuitive) change is to enable command line recall. This requires several changes:

 

1. Your shell must be the POSIX shell (/usr/bin/sh or /sbin/sh) or ksh. Note that the Bourne shell is obscured in the /usr/old/bin directory -- don't use it.

 

2. Edit your .profile to add these lines:

 

export HISTFILE=$HOME/.sh_history

export HISTSIZE=5000

export EDITOR=/usr/bin/vi

 

3. Create the history file:

 

touch $HOME/.sh_history

 

4. Logout and login again. Type a command like ls. Then type ESC k (the Escape key followed by the letter k). You should see the ls command echoed on the line ready to edit. Verify that the history can be shown by typing the command: history

 

There are several command line recall/edit features. Read the man pages for sh-posix (shortcut: man fc) or man ksh and look for Command Line Editing and vi Editing.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation