<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SOX and Shell History in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400493#M200710</link>
    <description>Can you post your .profile?&lt;BR /&gt;&lt;BR /&gt;I tried print -s  - but it somehow wiped out entries:&lt;BR /&gt;&lt;BR /&gt;# Set up logging&lt;BR /&gt;HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`&lt;BR /&gt;export HISTFILE&lt;BR /&gt;# print -s makes a mess&lt;BR /&gt;#print -s $(date) &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;date &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;HISTSIZE=500&lt;BR /&gt;export HISTSIZE&lt;BR /&gt;&lt;BR /&gt;The only way I see you doing this is to make a copy dailey, then parse out the info you need in a separate file...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
    <pubDate>Thu, 14 Oct 2004 14:54:52 GMT</pubDate>
    <dc:creator>Geoff Wild</dc:creator>
    <dc:date>2004-10-14T14:54:52Z</dc:date>
    <item>
      <title>SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400492#M200709</link>
      <description>Hi all!&lt;BR /&gt;&lt;BR /&gt;Our Security team is wanting us to track our shell history files daily for Sarbanes-Oxley compliance.  &lt;BR /&gt;&lt;BR /&gt;We long ago separated our root history files utilizing 'logname' and building HISTFILE based on that.  So we know who is doing what since you can't get to root except by sudo or the console.&lt;BR /&gt;&lt;BR /&gt;Our problem is that we can't figure out a good way to just pull out today's commands from the history file.  Well the easy way is to start a new one each day....  But then we don't have access to our history from the previous day.&lt;BR /&gt;&lt;BR /&gt;So I thought I would just write an entry to the history file that would actually be a NO-OP command that would signify login in and logout.  &lt;BR /&gt;&lt;BR /&gt;Well I am getting it into the file easy enough using tee.  But I am missing something in the format of the file that is really horking up the first command after relogin.&lt;BR /&gt;&lt;BR /&gt;Any ideas?  Any better ways of doing this?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Eric</description>
      <pubDate>Thu, 14 Oct 2004 14:48:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400492#M200709</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-14T14:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400493#M200710</link>
      <description>Can you post your .profile?&lt;BR /&gt;&lt;BR /&gt;I tried print -s  - but it somehow wiped out entries:&lt;BR /&gt;&lt;BR /&gt;# Set up logging&lt;BR /&gt;HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`&lt;BR /&gt;export HISTFILE&lt;BR /&gt;# print -s makes a mess&lt;BR /&gt;#print -s $(date) &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;date &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;HISTSIZE=500&lt;BR /&gt;export HISTSIZE&lt;BR /&gt;&lt;BR /&gt;The only way I see you doing this is to make a copy dailey, then parse out the info you need in a separate file...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Thu, 14 Oct 2004 14:54:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400493#M200710</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-14T14:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400494#M200711</link>
      <description>Actually this pretty straight forward.  I am not attempting to log the logins, just the logouts.&lt;BR /&gt;&lt;BR /&gt;This is the section that does our history file stuff:&lt;BR /&gt;&lt;BR /&gt;###&lt;BR /&gt;###&lt;BR /&gt;   export WHOROOT=`/usr/bin/logname`&lt;BR /&gt;   if [ -z "$WHOROOT" ]; then&lt;BR /&gt;      WHOROOT=`echo $(who -Rm) | awk '{print $1}'`&lt;BR /&gt;   fi&lt;BR /&gt;   if [ "$WHOROOT" = "root" -a "`tty`" != "/dev/console" ]; then&lt;BR /&gt;      echo "\n\nYOU ARE LOGGED IN AS ROOT!!!"&lt;BR /&gt;      echo "PLEASE LOG IN AS YOURSELF AND "&lt;BR /&gt;      echo "ISSUE THE SUROOT COMMAND!!!\n\n"&lt;BR /&gt;      ISROOT=1&lt;BR /&gt;   else&lt;BR /&gt;      ISROOT=0&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;export PS1="&lt;BR /&gt;`echo "["'$PWD'"]"`&lt;BR /&gt;$LOGNAME on `uname -n` -# "&lt;BR /&gt;&lt;BR /&gt;typeset -l ANSWER=""&lt;BR /&gt;while [ -z "$ANSWER" ]; do&lt;BR /&gt;&lt;BR /&gt;   if [ "$WHOROOT" != "root" ]; then&lt;BR /&gt;      ANSWER=$WHOROOT&lt;BR /&gt;   else&lt;BR /&gt;      echo "Who are you? \c"&lt;BR /&gt;      read ANSWER&lt;BR /&gt;   fi&lt;BR /&gt;   case $ANSWER in&lt;BR /&gt;    eric|ebuckner)&lt;BR /&gt;        export HISTFILE=~/.sh_history.eric&lt;BR /&gt;        continue;;&lt;BR /&gt;    phil|pgifford)&lt;BR /&gt;        export HISTFILE=~/.sh_history.phil&lt;BR /&gt;        continue;;&lt;BR /&gt;    *)&lt;BR /&gt;        export HISTFILE=~/.sh_history.$ANSWER&lt;BR /&gt;        continue;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;trap $HOME/.logout 0&lt;BR /&gt;&lt;BR /&gt;###&lt;BR /&gt;###&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The reason for multiple answers in the case, is so we can identify ourselves when logging in as root on the console so we have access to our own histories.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now I know the history file has nulls in it but can determine what else it has in it that is being used as line control so I am experimenting w/ this format.&lt;BR /&gt;&lt;BR /&gt;This is the .logout script:&lt;BR /&gt;echo "\0000logout at `date`\n\0000" | tee -a $HISTFILE&lt;BR /&gt;&lt;BR /&gt;We have a script called logout that does absolutely nothing.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Oct 2004 15:04:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400494#M200711</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-14T15:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400495#M200712</link>
      <description>Geoff,&lt;BR /&gt;   Hey man you actually have it.  You just don't want to redirect print -s .&lt;BR /&gt;&lt;BR /&gt;   I just changed my .logout to:&lt;BR /&gt;&lt;BR /&gt;print -s "logout at `date`"&lt;BR /&gt;&lt;BR /&gt;and it is doing exactly what I want.  &lt;BR /&gt;&lt;BR /&gt;Repost so I can give you some more points.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Oct 2004 15:10:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400495#M200712</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-14T15:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400496#M200713</link>
      <description>Hi Eric,&lt;BR /&gt;&lt;BR /&gt;run a cron job to append in the .sh_history file.&lt;BR /&gt;&lt;BR /&gt;01 00 * * * echo `date` &amp;gt;&amp;gt;/.sh_history&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Regds&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Oct 2004 15:13:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400496#M200713</guid>
      <dc:creator>Sanjay_6</dc:creator>
      <dc:date>2004-10-14T15:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400497#M200714</link>
      <description>Make sure you test the print -s&lt;BR /&gt;&lt;BR /&gt;I found I lost a bunch of my history....&lt;BR /&gt;&lt;BR /&gt;But you are not redirecting - how are you doing it?&lt;BR /&gt;&lt;BR /&gt;This is waht I determined:&lt;BR /&gt;&lt;BR /&gt;date &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;&lt;BR /&gt;Which causes the first command to be appeneded to the date in the .sh_history file&lt;BR /&gt; &lt;BR /&gt;I figured out a way to get the date on it's own line:&lt;BR /&gt; &lt;BR /&gt;print -s $(date) &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt; &lt;BR /&gt;The -s option causes the arguments to be written onto the history file instead of standard output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Thu, 14 Oct 2004 15:30:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400497#M200714</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-14T15:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400498#M200715</link>
      <description>Geoff,&lt;BR /&gt;   You don't need to redirect.  As you said the print -s handles putting it in the log file nicely.  &lt;BR /&gt;&lt;BR /&gt;    I am doing this is my .profile:&lt;BR /&gt;    print -s "LOGIN - `date '+%E%m%d'`"&lt;BR /&gt;&lt;BR /&gt;    and my .logout&lt;BR /&gt;    print -s "LOGOUT - `date '+%E%m%d'`"&lt;BR /&gt;&lt;BR /&gt;   I then created 2 scripts called LOGIN and LOGOUT that only have an exit in them to protect me from accidently attempting to execute them.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sanjay,&lt;BR /&gt;   While the redirection of date isn't a good idea, I can see using the cron entry to mark the beginning and end of day using a print -s rather than having multiple entries everytime someone logs in.</description>
      <pubDate>Thu, 14 Oct 2004 15:42:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400498#M200715</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-14T15:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400499#M200716</link>
      <description>Eric,&lt;BR /&gt;&lt;BR /&gt;Nice work...&lt;BR /&gt;&lt;BR /&gt;Now, I'm trying to run this from root's cron at midnight:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;# script to add a date stamp to the /.sh_history_$USER&lt;BR /&gt;# for those su'ed to root&lt;BR /&gt;# Only run from cron once a day&lt;BR /&gt;# gwild 2004-10-15&lt;BR /&gt;# set -x&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# find parent process of all users signed in as root&lt;BR /&gt;for i in `ps -ef |grep "\-sh"|awk '{print $3}'`&lt;BR /&gt;do&lt;BR /&gt;  # just grab the user name&lt;BR /&gt;  USER=`ps -ef |grep $i |grep -v root|awk '{print $1}'`&lt;BR /&gt;  # point to their .sh_history file&lt;BR /&gt;  typeset -x HISTFILE=${HOME}/.sh_history_$USER&lt;BR /&gt;  # time stamp it&lt;BR /&gt;  print -s "`/usr/bin/date` $USER still logged in as root..."&lt;BR /&gt;  unset HISTFILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Unfortunatley, the print -s outputs to the first user in the list only - for all users...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tail /.sh_history_gwild&lt;BR /&gt;&lt;BR /&gt;Mon Oct 18 08:55:00 MDT 2004 gwild still logged in as root...&lt;BR /&gt;Mon Oct 18 08:55:00 MDT 2004 user2 still logged in as root...&lt;BR /&gt;Mon Oct 18 08:55:01 MDT 2004 user3 still logged in as root...&lt;BR /&gt;ls -altr&lt;BR /&gt;tail .sh_history_gwild&lt;BR /&gt;&lt;BR /&gt;Output with set -x:&lt;BR /&gt;&lt;BR /&gt;+ ps -ef&lt;BR /&gt;+ grep \-sh&lt;BR /&gt;+ awk {print $3}&lt;BR /&gt;+ + ps -ef&lt;BR /&gt;+ grep 8983&lt;BR /&gt;+ grep -v root&lt;BR /&gt;+ awk {print $1}&lt;BR /&gt;USER=gwild&lt;BR /&gt;+ typeset -x HISTFILE=//.sh_history_gwild&lt;BR /&gt;+ /usr/bin/date&lt;BR /&gt;+ print -s Mon Oct 18 08:53:16 MDT 2004 gwild still logged in as root...&lt;BR /&gt;+ unset HISTFILE&lt;BR /&gt;+ + ps -ef&lt;BR /&gt;+ grep 737&lt;BR /&gt;+ grep -v root&lt;BR /&gt;+ awk {print $1}&lt;BR /&gt;USER=user2&lt;BR /&gt;+ typeset -x HISTFILE=//.sh_history_user2&lt;BR /&gt;+ /usr/bin/date&lt;BR /&gt;+ print -s Mon Oct 18 08:53:16 MDT 2004 user2 still logged in as root...&lt;BR /&gt;+ unset HISTFILE&lt;BR /&gt;+ + ps -ef&lt;BR /&gt;+ grep 12746&lt;BR /&gt;+ grep -v root&lt;BR /&gt;+ awk {print $1}&lt;BR /&gt;USER=user3&lt;BR /&gt;+ typeset -x HISTFILE=//.sh_history_user3&lt;BR /&gt;+ /usr/bin/date&lt;BR /&gt;+ print -s Mon Oct 18 08:53:16 MDT 2004 user3 still logged in as root...&lt;BR /&gt;+ unset HISTFILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Oct 2004 10:00:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400499#M200716</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-18T10:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400500#M200717</link>
      <description>Geoff,&lt;BR /&gt;   Yeah I had the same problem.  I gave up on it and put in an AT job for what I needed.  I figured I will come back to it later.  &lt;BR /&gt;&lt;BR /&gt;   It seems like it is binding the HISTFILE the first time around and even though you unset it, it still has a lock on the inode and doesn't release it.&lt;BR /&gt;&lt;BR /&gt;   One option would be to put the part that sets the HISTFILE and does the print -s in a subshell.  That would possibly allow it to release the inode.</description>
      <pubDate>Tue, 19 Oct 2004 12:12:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400500#M200717</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-19T12:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400501#M200718</link>
      <description>Geoff,&lt;BR /&gt;   I got this working.  Unfortunately I can't think of a cleaner way to do it than 2 separate scripts so here they are:&lt;BR /&gt;&lt;BR /&gt;script1.sh: &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;ADMINS="you me"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for NAME in $ADMINS; do&lt;BR /&gt;&lt;BR /&gt;   HIST=/root/.sh_history.$NAME&lt;BR /&gt;   script2.sh $HIST&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;### End of script1.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;script2.sh:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;export HISTFILE=$1&lt;BR /&gt;&lt;BR /&gt;print -s "### Test"&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;### End of script2.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can add what ya need in there for checking who is logged in and what not.</description>
      <pubDate>Tue, 19 Oct 2004 12:27:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400501#M200718</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-19T12:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400502#M200719</link>
      <description>Eric, check out the solution in my thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=722093" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=722093&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Tue, 19 Oct 2004 12:43:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400502#M200719</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-19T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400503#M200720</link>
      <description>Geoff,&lt;BR /&gt;  GREAT!  I was getting there, and love the subshell thing in the function.  &lt;BR /&gt;&lt;BR /&gt;   One thing I would suggest because it bit me a few minutes ago while testing this.  Make sure you put some #'s at the beginning of your print -s.  ie print -s "### `date`".  That way if you do try to execute it, it is a comment and won't work.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Oct 2004 13:18:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400503#M200720</guid>
      <dc:creator>Eric Buckner</dc:creator>
      <dc:date>2004-10-19T13:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: SOX and Shell History</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400504#M200721</link>
      <description>Eric - good idea on the ###'s&lt;BR /&gt;&lt;BR /&gt;I modified my script and also added to root's .profile:&lt;BR /&gt;&lt;BR /&gt;# Set up logging&lt;BR /&gt;HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`&lt;BR /&gt;export HISTFILE&lt;BR /&gt;print -s "### login at `/usr/bin/date` ###"&lt;BR /&gt;#date &amp;gt;&amp;gt;$HISTFILE&lt;BR /&gt;HISTSIZE=500&lt;BR /&gt;export HISTSIZE&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Oct 2004 13:52:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sox-and-shell-history/m-p/3400504#M200721</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-10-19T13:52:50Z</dc:date>
    </item>
  </channel>
</rss>

