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

This is a discussion on Is it possible to save all the commands typed in a shell into a log file? - Embedded ; 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 Thread
Results 1 to 12 of 12

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

  1. 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


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

    2007-10-01, 21:50(-00), Wei Wang:
    > 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


    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

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

    On Oct 2, 8:51 am, Stephane CHAZELAS wrote:
    > 2007-10-01, 21:50(-00), Wei Wang:
    >
    > > 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

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


    more info on how to enable it?


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

    2007-10-02, 14:07(-00), Wei Wang:
    [...]
    >> Yes, most shells have support for automatically saving the
    >> history in a file.

    [...]
    >
    > more info on how to enable it?


    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

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

    On Oct 2, 3:33 pm, Stephane CHAZELAS wrote:
    > 2007-10-02, 14:07(-00), Wei Wang:
    > [...]
    >
    > >> Yes, most shells have support for automatically saving the
    > >> history in a file.

    > [...]
    >
    > > more info on how to enable it?

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


    I am using csh, seems different from zsh


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

    2007-10-03, 12:58(-00), Wei Wang:
    [...]
    > I am using csh, seems different from zsh


    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

  7. Re: Is it possible to save all the commands typed in a shell into alog file?

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

    > 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


    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

  8. Re: Is it possible to save all the commands typed in a shell intoa log file?

    >
    > Yes, csh is different from zsh.


    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

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

    2007-10-04, 10:14(+02), Michael Schnell:
    >>
    >> Yes, csh is different from zsh.

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

    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

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

    2007-10-04, 09:27(+00), Stephane CHAZELAS:
    [...]
    > (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

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

    --
    Stéphane

  11. Re: Is it possible to save all the commands typed in a shell intoa log file?

    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

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

    2007-10-04, 12:42(+02), Michael Schnell:
    > Really horrible !
    >
    > I thought, the bash that is implemented in busybox would be standard in
    > embedded Linux.


    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.

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

    [...]

    Yes, busybox is optimized for size, not portability.

    --
    Stéphane

+ Reply to Thread