- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sh_history file format
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
06-24-2003 07:24 AM
06-24-2003 07:24 AM
sh_history file format
The .sh_history file is not entirely text. There is also special characters in this file. Does anybody know more about the format of the .sh_history?
I write a C prog which read this file...
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:27 AM
06-24-2003 07:27 AM
Re: sh_history file format
Its supposed to be all text.
Its a text log file.
All it is supposed to be is a record of keystrokes from the user at the prompt.
Maybe you want to upload this file and show us curious ones whats in it.
Inquiring minds want to know.
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
06-24-2003 07:29 AM
06-24-2003 07:29 AM
Re: sh_history file format
Sometimes it does have some binary characters in it. When I want to view it I do this:
strings .sh_history | more
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:29 AM
06-24-2003 07:29 AM
Re: sh_history file format
.sh_history is 100% text. It reflects 100 %what one types at the command line. If there is a typo or a non-readable character, it is logged in .sh_history as well.
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:32 AM
06-24-2003 07:32 AM
Re: sh_history file format
file .sh_history to see the file type.
I do however see some control characters in mine from time to time and it probably just catches them just like it catches commands.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:33 AM
06-24-2003 07:33 AM
Re: sh_history file format
I checked on our systems and indeed there are some special characters inside the file. Doing a more should be no problem but a cat gives you the beeps :)
When reading the file there should be no unexpected end of lines or so, so there should be no real problem when reading the file. I gues you should open it as a normal text-file.
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:44 AM
06-24-2003 07:44 AM
Re: sh_history file format
As previously said, .sh_history logs the command history of the shell. These special characters would have come into the file if you had typed some control chars in the shell followed by enter. This will get recorded into the file.
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:44 AM
06-24-2003 07:44 AM
Re: sh_history file format
If "strings" command works for you, then instead of :
fopen(".sh_history", ...)
you could use a :
popen("strings .sh_history")
which would do the filtering for use. It returns a FILE * descriptor like popen, but don't forget the pclose() ...
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:42 AM
06-24-2003 08:42 AM
Re: sh_history file format
If you think that sh_history is only ascii file, use bvi or od and you'll see extra characters like ^A or ^B :))))
My C prog open a user session and trace every user command in a log file. Each time the user press the enter key, the last line in .sh_history is read and copied in anoter file to keep the trace. I wrote a version which use fopen. Even with fopen, I can see some extra characters (not all) in the final log! A solution is to reject all characters < 0x20. I will test...
:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:53 AM
06-24-2003 08:53 AM
Re: sh_history file format
strings .sh_history >yourfile
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 11:50 AM
06-24-2003 11:50 AM
Re: sh_history file format
A string on the file will not display the non printable chars
so:-
strings .sh_history > /tmp/shellhist will produce a clean printable file.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 03:31 PM
06-24-2003 03:31 PM
Re: sh_history file format
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2003 11:44 AM
06-25-2003 11:44 AM
Re: sh_history file format
But if you're gonna, then....
You can cover tracks without the symptom by:
grep -v {command I want to hide} .sh_history > tmp
mv tmp .sh_history
Now, of course, you end up with the grep and mv in the history, but a little script that removes itself, named after an innocuous command like ls, and a slight path manipulation can leave almost no trace.
We'll let you guys work out the details.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2003 02:23 PM
06-25-2003 02:23 PM
Re: sh_history file format
xd $HISTFILE
or
xd -c $HISTFILE
against
head $HISTFILE
or
more $HISTFILE
-that gives enough details about it??s format.
Anyway, there are no details on that in
man sh-posix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2003 02:30 PM
06-25-2003 02:30 PM
Re: sh_history file format
.sh_history is purposefully embedded with special characters for the purpose of 'fc' comand as stated by Bill.
To see those special characters do
cat -v .sh_history
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2003 02:13 AM
06-26-2003 02:13 AM
Re: sh_history file format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2003 03:39 AM
06-26-2003 03:39 AM
Re: sh_history file format
at least the ksh has the option '-s' for the builtin commands read and print, which perform a write to the $HISTFILE.
Perhaps you can look into the pdksh-source to find out what has to be done for a read ...
mfG Peter