- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: HISTFILE env variable problems
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2004 10:36 PM
10-19-2004 10:36 PM
This is my 1st posting on the ITRC.
Here's my problem.
All local filesystems on a single server.
Assume user login is fred.
System profile /etc/profile sets and exports fred's HISTFILE=/tmp/.sh_history_fred
When fred adds the following to their own .profile
unset HISTFILE
HISTFILE=/home/fred/.sh_history_fred
export HISTFILE
The HISTFILE remains as /tmp/.sh_history_fred when displaying the env after login.
If you add an
echo "$HISTFILE" as the final line in the .profile it shows it set as /home/fred/.sh_history_fred
But as soon as login prompt is back after running .profile the HISTFILE variable is back to /tmp/.sh_history_fred
What's going on ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2004 10:41 PM
10-19-2004 10:41 PM
Re: HISTFILE env variable problems
More important, its obvious that the HISTFILE is being changed elsewhere, after your change.
You can start out with /etc/profile , and look for any source (script, program) called that might change it. Then look at .profile and see if its overriding your session.
When I'm in a hurry I just put my logic on the last line of .profile
Anything in .profile after the HISTFILE called with the dot space . myfile can change the setting.
Its also possible that an application is changing the variable after .profile is running.
You can put a set -x in .profile and get more verbose output.
This is really a detective story, where you look until you find the culprit. Its out there, but it may be hard to find.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 12:47 AM
10-20-2004 12:47 AM
Re: HISTFILE env variable problems
set -o vi
export HISTSIZE=9999
unset HISTFILE
HISTFILE=/home/fred/.sh_history_fred
export HISTFILE
The HISTFILE still reverts back to /tmp/.sh_history_fred after .profile has run.
Funnily enough /etc/profile exports HISTSIZE=1000
then the users .profile re-sets this variable to equal 9999.
This is changed successfully after .profile has run but still not the value of HISTFILE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 12:58 AM
10-20-2004 12:58 AM
Re: HISTFILE env variable problems
See what is happeneing.
set -o vi
export HISTSIZE=9999
unset HISTFILE
echo $?
HISTFILE=/home/fred/.sh_history_fred
export HISTFILE
The HISTFILE still reverts back to /tmp/.sh_history_fred after .profile has run.
Funnily enough /etc/profile exports HISTSIZE=1000
then the users .profile re-sets this variable to equal 9999.
This is changed successfully after .profile has run but still not the value of HISTFILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 02:03 AM
10-20-2004 02:03 AM
Re: HISTFILE env variable problems
After adding set -x
as the first line in /etc/profile and the users .profile
I saw the following occur:
+
+
+
USER=`who am i | cut -d\ -f1`
+ + who am i
+ cut -d -f1
USER=fred
HISTFILE=/tmp/.sh_history.$USER
+ HISTFILE=/tmp/.sh_history.fred
So it looks like both profiles run OK then shell jumps out and resets the HISTFILE.
This still occurs when I remove the original HISTFILE assignment in /etc/profile and the re-assignment in the users .profile
Very weird, any ideas ..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 02:27 AM
10-20-2004 02:27 AM
Re: HISTFILE env variable problems
man sh-posix shows:
"HISTFILE
If this parameter is set when the shell is invoked, its value is the path name of the file that is used to store the command history."
So you could read that to say you have but one chance. On entry and not again. Once the shell is there, setting HISTFILE will not change the actual history file because the shell is not re-invoked. If so, it is reasonable that the variable returns the actual = original history file name versus some un-used redefinition.
Also, when experimenting with scripts to test this, be sure to 'source' them with the extra dot: . ./test
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 02:28 AM
10-20-2004 02:28 AM
Re: HISTFILE env variable problems
---
Try on /etc/profile file end as,
-- /etc/profile --
if [[ $LOGNAME = "fred" ]]
then
set -x
echo $HISTFILE
export HISTFILE=/home/fred/.sh_history_fred
echo $HISTFILE
set +x
fi
--- /home/fred/.profile --
set -x
echo $HISTFILE
export HISTFILE=/home/fred/.sh_history_real
echo $HISTFILE
set +x
Try to login as fred and you will be notified with changes there.
On the login, your history file will be shown as,
/home/fred/.sh_history_real
Try and tell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 02:54 AM
10-20-2004 02:54 AM
Re: HISTFILE env variable problems
I think there is a long-haired explanation in Document id: 4000041319
Try this link:
http://www4.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000066026078
or look for the document in the tech base.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 02:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 03:02 AM
10-20-2004 03:02 AM
Re: HISTFILE env variable problems
I knew I wasn't going mad!
Magic Answer - solved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 03:03 AM
10-20-2004 03:03 AM