Solved

How to get history of command in AIX5.3

Posted on 2009-04-12
8
1,680 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
Comment Utility
Try to check what is your shell. This is supported in shells like bash and ksh
0
 

Author Comment

by:sachin_dba
Comment Utility
hOW TO CHECK SHELL?
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
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
 

Expert Comment

by:DbLanMan
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Expert Comment

by:DbLanMan
Comment Utility
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 61

Expert Comment

by:gheist
Comment Utility
set -o vi

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

Accepted Solution

by:
dfke earned 250 total points
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now