Operating System - HP-UX
1832590 Members
3283 Online
110043 Solutions
New Discussion

HISTFILE=_____ works for root but not other IDs.

 
SOLVED
Go to solution
Thomas D. Harrison
Frequent Advisor

HISTFILE=_____ works for root but not other IDs.

Placing the following in /.profile works fine for root. It creates
/.roothist/log.yymmdd.hhmmss and uses it as the history file.

STAMP=`date +%y%m%d.%I%M%S`
export HISTFILE=$HOME/.hist/log.$STAMP

Unfortunately, I can't get get it to work for other IDs. ( oracle for instance ).

After logging in as oracle, I can do a:
$ echo $HISTFILE
and I get the correct path and filename but the file is never created nor used as the history file. I had already created the directory and ensured that oracle had proper permissions to it. oracle continues to use .sh_history.

Any ideas?

Thanks.

Thom
Imbibo ergo sum.
15 REPLIES 15
Holger Knoppik
Valued Contributor

Re: HISTFILE=_____ works for root but not other IDs.

Hi Thomas,

try the following:
export HISTFILE=$HOME/.hist/log.$`STAMP`

I had to use this for making timestamps by scripts. The problem is that the shell has to refresh the timestamp by executing date.

HTH,
RGDS, Holger
Live long and prosper!
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Thanks Holger,

Unfortunately I can even use:

HISTFILE=$HOME/.hist
HISTSIZE=500
export HISTFILE HISTSIZE

and it doesn't seem to work.

I'll keep that TIMESTAMP trick in mind though.

Thom
Imbibo ergo sum.
Thierry Poels_1
Honored Contributor

Re: HISTFILE=_____ works for root but not other IDs.

Hi,

the HISTFILE variable contains a subdirectory. Is the subdir created for the relevant users?? And are the privileges OK for these users?

Otherwise creating the file (touch) in advance with the right privileges might help.

good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Martin Johnson
Honored Contributor

Re: HISTFILE=_____ works for root but not other IDs.

You also have to define the EDITOR:

EDITOR=/usr/bin/vi; export EDITOR


Marty
Rodney Hills
Honored Contributor
Solution

Re: HISTFILE=_____ works for root but not other IDs.

Is it possible that with your root login, you do an "exec" to another shell?

According to the man page for "sh-posix", when you set HISTFILE, only the next shell that is launched would use the assigned filename.

So if you assign HISTFILE in .profile, not until another shell is launched will it use the defined file for history.

-- Rod Hills
There be dragons...
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Thanks Thierry,

I added a > $HOME/.hist/log.$STAMP

before the export HISTFILE= statement and
it created the file but still doesn't use it.

As soon as I login I tried the following:

Rights for non-DOD U.S. Government Departments and Agencies are as set
forth in FAR 52.227-19(c)(1,2).

QADB$ echo $HISTFILE
/home/tdharri/.hist/log.020619.090924
*** HISTFILE has the correct value.

QADB$ ll -d .hist
drwxr-xr-x 2 tdharri users 96 Jun 19 09:09 .hist
*** .hist perms should be okay.

QADB$ ll .hist
total 0
-rw-r--r-- 1 tdharri users 0 Jun 19 09:09 log.020619.090924
*** As you can see the log file was created but it isn't being used. .sh_history is still the history file.

???
Imbibo ergo sum.
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Martin: Both IDs have the following in their .profile before the HISTFILE stuff.

EDITOR=vi
export EDITOR

Rodney: Neither .profile has an exec anywhere in it.

Thanks.

Thom

Imbibo ergo sum.
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Rodney,

I think you're on the right track. If I log in the new history file doesn't work. However,
if I "su tdharri" it does.

Thanks a lot.

Thom
Imbibo ergo sum.
Rodney Hills
Honored Contributor

Re: HISTFILE=_____ works for root but not other IDs.

I found that I must assign HISTFILE prior to defining any functions in my .profile. Somehow the function definition are logged to the history file. Once it has opened .sh_history for writing, it will ignore whatever HISTFILE has.

-- Rod Hills
There be dragons...
Martin Johnson
Honored Contributor

Re: HISTFILE=_____ works for root but not other IDs.

Do a "set -o" to get a listing of variables. Check to see if "vi on". If it is off do "set -o vi".


Marty
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Rod,

I tried both of the following combinations at the very beginning of my .profile.

1)
EDITOR=vi; export EDITOR
export HISTFILE=$HOME/.hist/log$$

2)
export HISTFILE=$HOME/.hist/log$$
EDITOR=vi; export EDITOR

No luck. :-(

As I mentioned, if I su tdharri after initially logging in I starts using the new history file.

Thanks.

Thom
Imbibo ergo sum.
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Marty,

set -o as tdharri showed that vi was ON.

Thanks.

Thom
Imbibo ergo sum.
Joey K. Harpole_1
Occasional Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Thom,

Are you using CDE? If so, for your .profile to work I think you have to modify $HOME/.dtprofile

Instructions for modifying .dtprofile are in the file.

Good Luck,
Joe
Thomas D. Harrison
Frequent Advisor

Re: HISTFILE=_____ works for root but not other IDs.

Joe,

We're actually using PuTTY SSH and not CDE. We also get the same issue with telnet.

Thanks for you idea.

Thom

Imbibo ergo sum.
Rodney Hills
Honored Contributor

Re: HISTFILE=_____ works for root but not other IDs.

/etc/profile gets processed first during shell login, before a users .profile files. Is it possible something in /etc/profile, like a function definition, would be writing to the history file?

-- Rod Hills
There be dragons...