Operating System - HP-UX
1832910 Members
2800 Online
110048 Solutions
New Discussion

How create 2 differente history file for the same login ?

 
cariteyp
Occasional Advisor

How create 2 differente history file for the same login ?

HPUX 11
Ksh
We are 2 people who use the same login (for database administration).
So we use the same history file.

I find a solution to know the client IP PC, then I can use specific variable for each users.
Where and what is the environment variable to solve this newbie problem ?

Thank you for you help.

What is the best solution to create
12 REPLIES 12
Pete Randall
Outstanding Contributor

Re: How create 2 differente history file for the same login ?

Pete Randall
Outstanding Contributor

Re: How create 2 differente history file for the same login ?

Sorry, should have mentioned this in the last response:

You shouldn't share the login. Login as yourself and then su to the DBA login.


Pete

Pete
Peter Nikitka
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,

use that approach to add the client hostname to the HISTFILE definition in .profile:
remhost=`who am i -R | awk '{print(substr($NF,2,length($NF)-2))}'`
HISTFILE=/tmp/hist.$LOGNAME.$remhost
export HISTFILE

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Peter Nikitka
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,

I forget to say it explicitly: my previous solution is NOT selecting different history files on a per username-of-incoming-user base but on a per localuser-of-incoming-hostname base.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
cariteyp
Occasional Advisor

Re: How create 2 differente history file for the same login ?

Here HISTFILE is not define.

I put in .profile :
HISTFILE=$HOME/.sh_history.tmp
export HISTFILE

I use an other terminal for a new login,
I test echo $HISTFILE
no problem.
But the history is always in .sh_history ?!
Peter Nikitka
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,

create the history file in using

touch $HISTFILE

Log off an on again, then do
echo $HISTFILE
pwd
ls -l $HISTFILE

Check/send the output.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
cariteyp
Occasional Advisor

Re: How create 2 differente history file for the same login ?

toto@hp2:/home/toto> echo $HISTFILE
/home/toto/.sh_history.tmp
toto@hp2:/home/toto> pwd
/home/toto
toto@hp2:/home/toto> ls -l $HISTFILE
-rw------- 1 toto dba 0 Jun 8 15:16 /home/toto/.sh_history.tmp
Peter Nikitka
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,

if you start a subshell, do you get entries in $HISTFILE ?

: /usr/bin/ksh
pwd
ls -l $HISTFILE

or as second test:
: exec /usr/bin/ksh
...

If that fails, send yout .profile.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
cariteyp
Occasional Advisor

Re: How create 2 differente history file for the same login ?

Indeed if I start a subshell, It's OK ....
Then I put in the end of .profile the line :
exec ksh

I don't know if it is the best solution, but it works ....

Thank you for you help.
Peter Nikitka
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,

perhaps you better try to put the HISTFILE stuff in ~/.kshrc like this:
In .profile:
...
ENV=~/.kshrc
export ENV

In .kshrc put all really ksh components:
HISTFILE=...
HISTSIZE=192
FCEDIT=vi
...

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Victor Fridyev
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,

I have a group of administrators who work with the same account, so in order to have different history files, I added to .profile:
export HISTFILE=/tmp/hist$(tty|sed 's?/??g')

HTH
Entities are not to be multiplied beyond necessity - RTFM
Victor BERRIDGE
Honored Contributor

Re: How create 2 differente history file for the same login ?

Hi,
The previous solutions should have worked...
The reason it doesnt will be diificult to answer for you didnt say HOW you connetc yourself!
If CDE for instance it may be you left in .dtprofile:
> # DTSOURCEPROFILE=true

So read carefully and if you meet the prereqs
uncomment the line!

Then it will take into account .profile


All the best
Victor