[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to get history of command in AIX5.3

Posted on 2009-04-12
8
Medium Priority
?
1,770 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

650 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