csh History

Hello everybody,

Im being unsuccessful to enable command history logging in csh shells on a Sun machine running Solaris 9, I know csh doesnt log commands history by itself,
here under is my /.cshrc file:

# @(#)cshrc.standard    1.1 Copyright 1994, Motorola Inc.

if ( -e /.datagen_system ) then

        source /usr/gsm/DataGen/current/config/local/cshrc.datagen

        if ( -f $HOME/.dg_profile ) then

                source $HOME/.dg_profile

        endif

else

source /usr/omc/current/env/.cshrc

endif

alias omc_env 'source /usr/omc/config/global/pmInfxUserConfig.csh'

alias mib_env 'source /usr/omc/config/global/mibInfxUserConfig.csh'

alias omclog tail -f /usr/omc/logs/omcaudit`date +%Y%m%d`

alias usrlog    tail -f /usr/omc/logs/usrauditlogs/usraudit`date +%Y%m%d`

alias h history

alias glu /usr/omc/ne_data/GLU

set filec

set histfile=/.history

set history=200

I also dded the following lines to my /etc/profile:

set histfile=/.history

set history=200

Thanks in advance
Aladdin

is there any daemon I should run???

Hi.

The /etc/profile is for Bourne-family shells, sh, bash, etc. If you placed those set commands in that file, you would effectively set the first argument to "history=200".

The shells are conceptually simple, they read in lines of text, usually interpret the first token as a command, run it, and wait for the next command to run. I am not aware of any connection to a daemon that would be necessary for the shells to run.

I have a very simple .cshrc file on Solaris 10:

#ident  "@(#)local.cshrc        1.2     00/05/01 SMI"
umask 022
set path=(/bin /usr/bin /usr/ucb /etc .)
if ( $?prompt ) then
        set history=32
endif

and the history mechanism works for me.

First things first: how do you know that you are running csh? ... cheers, drl

Thanks for your reply drl,

I tried also commenting the two lines in /etc/profile but still same result.
as for knowing the shell, emmm. actually Im using "ps" command, and "echo $$", is that right???
but it is still not running, I will post any solution might work.

Regards
Aladdin

Hi.

Here is how I quickly check to see what shell I am using:

vm-solaris% ps | grep $$
   666 pts/2       0:00 csh

If you were actually using bash, it would look like this:

vm-solaris drl ~ $ ps | grep $$
   585 pts/2       0:00 bash

We need to refine the question a bit. Are you getting any output what you enter:

history

or are you concerned about the lack of a command history across a login -- that is, when you login again, there is no history? If that is true then you probably need something like:

set savehist=10

in .cshrc ... cheers, drl

Hi drl,
and thanks again for your help.

the output for "ps" was csh:

cl1# ps | grep $$
  7344 pts/1       0:00 csh
cl1# history
cl1# set savehist=10
cl1# history
cl1# ./.cshrc
/usr/omc/current/env/.cshrc: No such file or directory
cl1# history
cl1#

as you can see the history command returned nothing, even though I set the savehist var, and added it to .cshrc and reinitialize the file.

Many Thanks
Aladdin

Hi.

Please enter the following commands, and post the output:

set history=5
echo one
history

The "savehist" command is for saving the history across logins ... cheers, drl

(We should talk about "... .cshrc: No such file ...", but we can do that later.)

Thanks alot drl,
seems it worked, what do you think was wrong, here is the output,

cl1# ps | grep $$
  7504 pts/1       0:00 csh
cl1# set history=5
cl1# echo one
one
cl1# history
     2  set history=5
     3  echo one
     4  history
cl1#

I will add set history to my .cshrc file.

Many thanks again

Aladdin

Hi, Aladdin.

Glad to hear that it seems to be working.

As to what was wrong -- I don't know. Perhaps the correct commands were not present at the right time and place.

The important thing is that you see that there is cause and effect for the appropriate commands to set up the history mechanism for the login name (account, user, etc.) that you are currently using.

Best wishes ... cheers, drl