1833601 Members
3324 Online
110061 Solutions
New Discussion

Using .sh_history

 
SOLVED
Go to solution
PeterCh
Occasional Advisor

Using .sh_history

Hi,

We have set the HISTFILE and HISTSIZE parameters in the user .profile in an Xwindows environment.

If the user does an su - user and logs in, then everything the user does is logged into the .sh_history file. Every day we will do an '> .sh_history' to zero the history file.

But if we open up a new xterm window or right click on the desktop and select a new xterm window, the newly entered commands are not logged into the .sh_history file. It seems like opening a new xterm window does not run the .profile, and the .profile needs to be run to make the history work, even though the xterm window is the correct user.

Is there any way around this problem, like forcing the .profile to run everytime a new xterm window is opened, or some other settings? Thanks in advance.
5 REPLIES 5
PeterCh
Occasional Advisor

Re: Using .sh_history

Also we have tried adding a
export HISTSIZE=5000 to the .profile, but the .sh_history file keeps on growing to much more than 5000 lines.

Is the .sh_history supposed to delete the old history lines when the HISTSIZE is reached, or what behavior should be expected?
Thanks!
Ninad_1
Honored Contributor

Re: Using .sh_history

Try putting an entry in .dtprofile in the users home directory.

Regards,
Ninad
Bill Hassell
Honored Contributor
Solution

Re: Using .sh_history

The problem is with Xwindows. Historically, the design for Xwindows, specifically xterm, hpterm and dtterm, is to bypass all normal login steps that a telnet, rlogin or ssh login would performa, namely, run /etc/profile and then .profile. The philosophy was that Unix profiles are incompatible with Xwindows but the reality is that there is nothing in a standard profile set that would interfere with X11 terminals.

Nevertheless, the terminal windows ignore profiles. This occurs because Xwindows terminal emulators do not set the flag to put a dash in front of the login shell (ie, -sh or -ksh, etc) and this tells the kernel not to run the standard profiles. To fix this, do this in every Xwindow user's $HOME directory:

echo "*loginShell: true" >> $HOME/.Xdefaults

Now when you start an X11 terminal window you will see the normal login (ie, copyright messages, etc) and your environment will be correct. Note: there is a DTSourceprofile option that may be mentioned -- ignore that advice. It will not run /etc/profile and that means that the system-wide settings and tests will not be performed.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Using .sh_history

>Also we have tried adding a
export HISTSIZE=5000 to the .profile, but the .sh_history file keeps on growing to much more than 5000 lines.

You will be able to see more than 5000 lines by looking at the file but history can only list the last 5000 lines. To me this is a GOOD thing.

>Is the .sh_history supposed to delete the old history lines when the HISTSIZE is reached, or what behavior should be expected?

You are not suppose to look behind the green curtain (.sh_history). ;-)

I've had the file reach 32K lines and then I have lots of problems. :-(
PeterCh
Occasional Advisor

Re: Using .sh_history

Thanks everyone, it is working!