- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to Set up history mechanism for command re...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:31 PM
05-27-2004 05:31 PM
In HP-UX11i OE,how to Set up history mechanism for command recall editing for users.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:35 PM
05-27-2004 05:35 PM
Solution# Set up logging
HISTFILE=${HOME}/.sh_history_`who am i|awk {'print $1'}`
date >> $HISTFILE
export HISTFILE
HISTSIZE=500
export HISTSIZE
This will keep a shell history for command recall.
In /usr/bin/sh ESC K will recall.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:36 PM
05-27-2004 05:36 PM
Re: How to Set up history mechanism for command recall editing
put HISTFILE=.sh_history in .profile of the $HOME of the user
with best wishes
naveej
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:44 PM
05-27-2004 05:44 PM
Re: How to Set up history mechanism for command recall editing
----------------------------------------
export HISTFILE=/tmp/$LOGNAME.sh_history
----------------------------------------
After adding this line either re-login or execute your . profile. You can execute your .profile as follows:
---------------------------
$ . ~/.profile
$
---------------------------
The histfile would be created in /tmp directory.
Regards,
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:44 PM
05-27-2004 05:44 PM
Re: How to Set up history mechanism for command recall editing
add on to above messages,
EDITOR=vi
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
HISTSIZE=1000
EXPORT EDITOR HISTFILE HISTSIZE
regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:45 PM
05-27-2004 05:45 PM
Re: How to Set up history mechanism for command recall editing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:46 PM
05-27-2004 05:46 PM
Re: How to Set up history mechanism for command recall editing
ESC K will recall the last command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:48 PM
05-27-2004 05:48 PM
Re: How to Set up history mechanism for command recall editing
Besides defining $HISTFILE and $HISTSIZE (that controls how many commands are saved) you can also choose the desired editor by defining $EDITOR EDITOR=vi or EDITOR=emacs.
Some people define a HISTFILE per login session such that simultaneous session do not share the history file (by using the proces id ($$) in the line HISTFILE=.sh_history_$$
Each time you login you start with an empty history.
Of course this leads to the problem that once in a while you must remove old history files (or remove the file on logout).
Check the shell's man page and search for HISTFILE and so on.
JP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 05:49 PM
05-27-2004 05:49 PM
Re: How to Set up history mechanism for command recall editing
If you are not able to recall your messages by using either escape-k or escape-'-' (excape minus), then you do following:
$ set -o vi
$ escape-k
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2004 06:03 PM
05-27-2004 06:03 PM
Re: How to Set up history mechanism for command recall editing
the simpliest way is this:
into $HOME/.profile put the following row:
export HISTFILE=~/sh_history
to be able to repeated commands you also would have this row in the same file:
set -o vi
and repeating is done like in vi via ESC (command mode) and than k
hope this will help you
br Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2004 02:03 AM
05-28-2004 02:03 AM
Re: How to Set up history mechanism for command recall editing
If a user is not using the korn shell, they can switch to the korn shell so history will be retained by doing the following:
$ exec ksh
$ set -o vi
Now, to go back through their history of commands they would simply do:
$
This will take them through their previous commands from recent to oldest, and they can use the vi movements to move through the line and change previous commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2004 02:04 AM
05-28-2004 02:04 AM
Re: How to Set up history mechanism for command recall editing
$ exec ksh
$ set -o vi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2004 02:18 AM
05-28-2004 02:18 AM
Re: How to Set up history mechanism for command recall editing
After setting history you have two options for command editing: vi and emacs. They can be set by
set -o vi
or
set -o emacs in .kshrc file.
vi is more powerful: in addition to ESC-k, ESC-j, ESC-h and ESC-l (moving up,down,right and left) you can find a pattern in history by ESC-/ and edit found command using vi commands (delete. replace etc). But if you prefer simplicity of emacs, you also may use this option with CTRL-P (previous), CTRL-N (next) and to move left and right by appropriate arrows.
HTH