This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Originally posted by kevin comario: Can I execute the history command in a bash script? If so could you tell me how so far I have been unsuccessful to do so.
Yes, why not? It's just like any shell script command. What errors are you getting ?
Joined: Jun 29, 2002
When I use the history command in a bash file it doesnt list anything. So i tried redirecting it to a temp file, and still nothing. Can an admin turn off such a function? Also I am using red hat if that makes a diffrence.
Hi Kevin, I dont think your problem is due to RedHat, rather it is due to bash's history function. By default, bash only enables history for interactive shells. Running a script does not fall under that category. You can turn history on in the script by using the <code>set -o history</code> command in your script. Your next problem (or security feature) is that the history you get will then be for that particular shell. You will not get a history for commands the user has typed. This is generally a good thing. The following script works on my system: