?
Solved

How to get history of command in AIX5.3

Posted on 2009-04-12
8
Medium Priority
?
1,760 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 750 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

764 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