Solved

How to get history of command in AIX5.3

Posted on 2009-04-12
8
1,722 Views
Last Modified: 2013-11-17
Whenever I press UP arrow at the command prompt to get the last typed command I got ERROR  ^[[A

Kindly Help

0
Comment
Question by:sachin_dba
8 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 24128033
Try to check what is your shell. This is supported in shells like bash and ksh
0
 

Author Comment

by:sachin_dba
ID: 24128555
hOW TO CHECK SHELL?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24128624
Hi,
for ksh and emacs-style editing -

define the following aliases in .profile or in a central profile:

alias __A=`echo "\020"`   # up arrow = ^p - previous cmd
alias __B=`echo "\016"`   # down arrow = ^n - next cmd
alias __C=`echo "\006"`   # right arrow = ^f - forward cursor
alias __D=`echo "\002"`   # left arrow = ^b - backward cursor

You need emacs-style cmdline editing mode for the above to work, so if you haven't done so already, add
set -o emacs to your .profile.

I don't know how to do this with vi-style editing mode, should be a bit more complicated. I found an example which exploits the KEYBD trap, but I never used it:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=822599

btw, check your shell e.g. by issuing

echo $0

The result should be the name of your shell program (ksh, bash or the like). A leading dash (-) means that it's a login shell.

Cheers and good luck!

wmp

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

by:DbLanMan
ID: 24129328
Follow these steps:
1- In the home directory of the AIX user, edit the .profile file. If it does not exist, create one. Note the "." in the file name ".profile". The dot makes it hidden file, it has to be hidden.
# vi .profile
2- In the file type the following:
set -o vi
3- Save and exit the file.
4- Log off and log back on again.
5- To get to the history, hit "esc" button and then the "-" button that will give you the last command you typed in the shell. Every time you hit the "-" key, you'll get the command before.
0
 

Expert Comment

by:DbLanMan
ID: 24129660
I should have mentioned that by doing so (adding "set -o vi" in the ".profile" file) , every time you hit the esc and "-", you can edit your command line as if you are editing a text line in "vi" editor. All vi editing commands will apply.
Thanks
0
 
LVL 62

Expert Comment

by:gheist
ID: 24136997
set -o vi

Esc+J/K/L/H
0
 
LVL 10

Accepted Solution

by:
dfke earned 250 total points
ID: 24210083
To determine which shell is in use, issue the AIX echo command:   echo $SHELL

while in  kornshell vi mode  (set -o vi) all entered commands are saved the the $HOME/.sh_history file.  It's read from the bottom up. Hit esc to enter vi mode  on the command line and press k for the previous entered command or go up one line in the .sh_history file if you will.  Press j to scroll down the .sh_history file for the next entered command.

Press i to go back to input mode again.

0
 

Author Closing Comment

by:sachin_dba
ID: 31569412
thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question