Solved

How to get history of command in AIX5.3

Posted on 2009-04-12
8
1,708 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sudo logging 5 92
Unix / Linux grid computing 5 156
IBM flash storage 840 15 62
FTP on FreeBSD server 2 126
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

776 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