Operating System - HP-UX
1829810 Members
2210 Online
109993 Solutions
New Discussion

Shell history not being written to specified history file

 
Brett Simpson
Frequent Advisor

Re: Shell history not being written to specified history file

Running 11.31 on Itanium.

Here's the output:
/bin/ksh:
$ B.11.31 Feb 27 2008 13:41:17 $
Version 11/16/88
builtin.c $Date: 2007/10/25 15:12:29 $Revision: r11.31/1 PATCH_11.31 (PHCO_37285)
test.c $Date: 2008/05/01 15:55:23 $Revision: r11.31/1 PATCH_11.31 (PHCO_38162)
$Revision: @(#) ksh88 R11.31_BL2008_0618_4 PATCH_11.31 PHCO_38162
OldSchool
Honored Contributor

Re: Shell history not being written to specified history file

are you logging in via a terminal (or terminal emulator) or are you running XWindows perhaps?
Brett Simpson
Frequent Advisor

Re: Shell history not being written to specified history file

Logging in via ssh using Putty.
OldSchool
Honored Contributor

Re: Shell history not being written to specified history file

1. If I login and then type ksh, then it starts logging to the correct history file. So, it appears that my ksh shell is not being invoked on login?

possibly...what's the shell listed it /etc/passwd?


2. I don't what you mean be "corrupted" file. It's not using NFS at all.

right, but a suggest was made the echo'ing the date into the file may have corrupted it.


3. Logging in via ssh using Putty.

ok..my original thought was the possibly you were logging in via XWindows and the default profile stuff wasn't being run. that doesn't appear to apply here.

A long shot: You might want to look at the PermitUserEnvironment setting is the sshd config, and see if there is an ~/.ssh/environment file. but be sure to note the warnings in the sshd_config and ssh manpages regarding their use.
Brett Simpson
Frequent Advisor

Re: Shell history not being written to specified history file

OldSchool,
I checked the sshd_config and that PermitUserEnvironment is set to "no".

I'm really at a loss on this one. I have two other servers that are somewhat identical to this one and I can HISTFILE to whatever I want and it works.
Peter Nikitka
Honored Contributor

Re: Shell history not being written to specified history file

Hi,

remove the default historyfile and retry again - perhaps this helps.

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"
Scott Lindstrom_2
Regular Advisor

Re: Shell history not being written to specified history file

Brett - I am having the *exact* same problem on only one of our servers. Did you ever get a resolution?

I have checked all the items in this thread and nothing seems to be causing the problem.

Scott
Bill Hassell
Honored Contributor

Re: Shell history not being written to specified history file

> date>>$HISTFILE

I believe that this is the problem. The POSIX shells (like ksh, HP's sh, bash, etc) create specialized binary file for the shell history. 99% of the file is ASCII but there are binary codes scattered throughout the file. The first 2 characters in a .sh_history file are SOH (CTRL-A or 0x01). You can see the effect when you edit .sh_history with vi (to remove traces of a mistake). Once edited, the history command (or fc -l) reports blank line numbers in the file. It appears that deleting or adding a line corrupts the file.

This problem comes up when trying to add a timestamp to the shell history file.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Shell history not being written to specified history file

>Bill: I believe that this is the problem.

Didn't I say that above? :-)
Scott Lindstrom_2
Regular Advisor

Re: Shell history not being written to specified history file

Let me try converting to the "print -s" method. While we have printed the datestamp directly to the file for years I can see how that could/would corrupt the file.

But would that cause the system to write history to .sh_history rather than whatever is in $HISTFILE? (A rhetorical question I guess).
Dennis Handly
Acclaimed Contributor

Re: Shell history not being written to specified history file

>Scott: But would that cause the system to write history to .sh_history rather than whatever is in $HISTFILE?

I'm not sure, why would the shell would check the file for validity?
Are you exporting HISTFILE at the top of ~/.profile? Does /etc/profile cause any history to be written sooner?
The documentation isn't clear when you can change/export it.
Sundar G
Frequent Advisor

Re: Shell history not being written to specified history file

Brett,
It works perfectly in my Itanium, 11.31 server, but "what /bin/ksh" shows a different date, "B.11.31 Oct 1 2008 01:54:10".

Might be bcause of the version