Is it possible to save all the commands typed in a shell into a log file?

I use "$ history" to get the last few commands typed in the shell window, but it is not so convenient, just wondering whether there are some better ways, though I believe there must be...:-) thanks ...-Wei

Reply to
Wei Wang
Loading thread data ...
2007-10-01, 21:50(-00), Wei Wang:

Yes, most shells have support for automatically saving the history in a file.

See

info -f zsh --index-search=HISTFILE

for zsh for instance. zsh has a number of other variables and options to fine tune the history handling (like how to behave when more than one zsh instance is running at a time, how to deal with dupplicates, how many entries to save...).

--
Stéphane
Reply to
Stephane CHAZELAS

more info on how to enable it?

Reply to
Wei Wang
2007-10-02, 14:07(-00), Wei Wang: [...]
[...]

All the information is in your shell's manual.

If your shell is zsh, you may put in your ~/.zshrc:

HISTFILE=~/.zsh-history HISTSIZE=500 SAVEHIST=5000

This will tell zsh to remember the last 500 commands in memory and last 5000 ones in the ~/.zsh-history file.

Again, see the manual for how you want to customise the history handling. For instance, I also have in my ~/.zshrc:

setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS HIST_SAVE_NO_DUPS \ HIST_VERIFY INC_APPEND_HISTORY NO_BANG_HIST

--
Stéphane
Reply to
Stephane CHAZELAS

I am using csh, seems different from zsh

Reply to
Wei Wang
2007-10-03, 12:58(-00), Wei Wang: [...]

Yes, csh is different from zsh. Now, all you need to do is look in your csh manual for how to do the same thing.

If you really are on an embedded Linux system, it's also possible that you've got a stripped down version of csh that doesn't have support for history saving. But why on earth would anyone put csh on an embedded Linux system?

--
Stéphane
Reply to
Stephane CHAZELAS

Am Mon, 01 Oct 2007 21:50:15 +0000 schrieb Wei Wang:

What about `man script` if it is available on your system. There you get all, typed in commands and outputted application replies.

Regards, Felix

--
Felix Tettamanti
Reply to
Felix Tettamanti

Why do all these different command shells exist (I did not even know csh and zsh. Do we also have ash, bsh, dsh, ... ysh ? :) )

-Michael

Reply to
Michael Schnell
2007-10-04, 10:14(+02), Michael Schnell:
[...]

They exist because people have wished to have features that were not in the shell they were using, so developped a new one with those features added.

Amongst the non-anecdotic modern shells, we distinguish 3 main families::

Bourne-like (the Bourne shell is a shell that was release with Unix V7 in 1979): Bourne shell, ash, ksh88, bash, zsh, pdksh, ksh93, dash, mksh (MirBSD ksh), posh.

csh like (the C shell has a common ancestor as the Bourne shell and used to be the shell of choice on BSDs) csh, tcsh

rc like (rc was plan9 (the could-have-been successor of Unix) shell): rc, es, (akanga)

(one may mention fish, which can't be classified in any of those categories, which may not be classified as anecdotics). Among the anecdotic shells, you can find shells with a perl or tcl or list syntax. In the embedded world, there also exists a number of very small shells with very limited functionalities, some being stripped down versions of some of the above.

zsh borrowed most of the most useful features of most other shells in the most sensible fashion, which makes it the ideal shell for interactive use.

For scripting, there is now a POSIX standard that describes a /language/ that is meant to be portable. Most moddern Bourne-like shells implement an interpreter for that language when called as "sh". bash, modern ash'es and ksh are known to be accurate interpreters of that language (but, of course, they have extensions over it which you can use when you use your shell at the prompt) which explains why most Unix systems base their standard "sh" on one of those.

--
Stéphane
Reply to
Stephane CHAZELAS
2007-10-04, 09:27(+00), Stephane CHAZELAS: [...]

^^^^ Sorry, I meant "lisp" syntax above.

--
Stéphane
Reply to
Stephane CHAZELAS

Really horrible !

I thought, the bash that is implemented in busybox would be standard in embedded Linux. Busybox can be configured to contain just what is needed and thus space problems should be solvable. But I do see that busybox contains stuff like cmdedit, ash, msh, lash and hush. ash, msh, lash and hush can be defined as default shell in the busybox configuration.

-Michael

Reply to
Michael Schnell
2007-10-04, 12:42(+02), Michael Schnell:

AFAIK, busybox doesn't have bash. bash is a poor choice of a POSIX shell for an embedded Linux, being quite bulky, not modular and with a lot of features that will probably never be of any use on an embedded system. If you want a POSIX shell, newer ash (as FreeBSD or debian ones, not busybox' which is not POSIX) or posh are probably more sensible alternatives, they should be 5 to 10 times as small.

[...]

Yes, busybox is optimized for size, not portability.

--
Stéphane
Reply to
Stephane CHAZELAS

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.