<?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: script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078625#M810909</link>
    <description>Steven, your script is &lt;NULL&gt; and it can not be opened at my end, for whatever reason.  Can you post your script to the webpage so I can see what you mean, with the double grep.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;David, A timeout setting at the OS before the connection is closed on the DB side, can be dangerous for data corruption.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;/NULL&gt;</description>
    <pubDate>Thu, 25 Sep 2003 14:32:11 GMT</pubDate>
    <dc:creator>Nick D'Angelo</dc:creator>
    <dc:date>2003-09-25T14:32:11Z</dc:date>
    <item>
      <title>script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078620#M810904</link>
      <description>Hello scriptors or is that scriptors?&lt;BR /&gt;&lt;BR /&gt;I have two scripts currently that I use to try and tell me who has been idle for greater than 1 hour &amp;gt; which writes the users out to a file.txt.  &lt;BR /&gt;Then the second script looks at this file.txt and does a grep to see if it is still connected to a db, Progress (_prog).  If they are, then write out to a  newfile.txt.&lt;BR /&gt;&lt;BR /&gt;My questions are this: Can I combine the two, hopefully, so that the system can generate and send the user an email asking them to logoff when idle.&lt;BR /&gt;Secondly, my second script appears to be catching users that do NOT meet the grep syntax.&lt;BR /&gt;&lt;BR /&gt;Suggestion/help appreciated.&lt;BR /&gt;&lt;BR /&gt;script one to check for idle users &amp;gt; 1 hour&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh &lt;BR /&gt;HOST=$(hostname) &lt;BR /&gt;EVERY=1 &lt;BR /&gt;&lt;BR /&gt;MESSAGE="please consider logging out" &lt;BR /&gt;#SUBJECT="You are IDLE on $HOST" &lt;BR /&gt;rm /home1/nickd/scripts/idleusers.txt&lt;BR /&gt;get_user() &lt;BR /&gt;{ &lt;BR /&gt;USER=$(echo $LINE|awk '{print $1}') &lt;BR /&gt;IDLE=$(echo $LINE|awk '{print $6}') &lt;BR /&gt;if [ "$IDLE" = "old" ] &lt;BR /&gt;then &lt;BR /&gt;echo $MESSAGE |mailx -s $SUBJECT $USER &lt;BR /&gt;#write $USER &amp;gt; /home1/nickd/scripts/idleusers.txt&lt;BR /&gt;else &lt;BR /&gt;IDLE_HOURS=$(echo $IDLE|awk '{FS=":";print $1}') &lt;BR /&gt;if [ "$IDLE_HOURS" -ge 1 ] &lt;BR /&gt;then &lt;BR /&gt;echo $USER &amp;gt;&amp;gt; /home1/nickd/scripts/idleusers.txt&lt;BR /&gt;#echo $MESSAGE |mailx -s $SUBJECT $USER &lt;BR /&gt;fi &lt;BR /&gt;fi &lt;BR /&gt;} &lt;BR /&gt;who -u|while read LINE &lt;BR /&gt;do &lt;BR /&gt;get_user $LINE &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Script 2 to see if they are still connected to db:&lt;BR /&gt;!/bin/sh&lt;BR /&gt;rm /home1/nickd/scripts/testuser.txt&lt;BR /&gt;for i in $(cat /home1/nickd/scripts/idleusers.txt)&lt;BR /&gt;do&lt;BR /&gt;#cat /home1/nickd/scripts/idleusers.txt |grep _pro |tee -a foundPatterns.txt&lt;BR /&gt;#ps -ef | grep $i | grep _prog | grep notrim &amp;gt; /home1/nickd/scripts/dbidle.txt&lt;BR /&gt;ps -ef | grep $i | grep notrim &amp;gt; /home1/nickd/scripts/dbidle.txt&lt;BR /&gt;print $i &amp;gt;&amp;gt; /home1/nickd/scripts/testuser.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Sep 2003 14:11:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078620#M810904</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2003-09-25T14:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078621#M810905</link>
      <description>I think the trouble is that in #1, you identify users who have been on too long, BUT the same user may have a newer session that has been logged in an acceptable amount of time (i.e. multiple logins for the same user).&lt;BR /&gt;&lt;BR /&gt;In your second script, you make no differentiation between the two.&lt;BR /&gt;&lt;BR /&gt;I think in script 1 that you need to copy the tty/pty combo into the idle users file and check those in the grep of the ps -ef instead of the user name.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Sep 2003 14:24:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078621#M810905</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-09-25T14:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078622#M810906</link>
      <description>Nick,&lt;BR /&gt;&lt;BR /&gt;Not exactly the answer to your question, but you can add a line like:&lt;BR /&gt;&lt;BR /&gt;TMOUT=600&lt;BR /&gt;&lt;BR /&gt;to the users .profile (or /etc/profile for all users). &lt;BR /&gt;&lt;BR /&gt;THis will log users out after 10 minutes of idle time.&lt;BR /&gt;&lt;BR /&gt;Of course they can always change their .profile and remove it.&lt;BR /&gt;&lt;BR /&gt;David</description>
      <pubDate>Thu, 25 Sep 2003 14:26:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078622#M810906</guid>
      <dc:creator>David Child_1</dc:creator>
      <dc:date>2003-09-25T14:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078623#M810907</link>
      <description>sometimes when you run grep it greps itself.&lt;BR /&gt; &lt;BR /&gt;I don't know why.&lt;BR /&gt; &lt;BR /&gt;Here is how to fix it.&lt;BR /&gt;&lt;BR /&gt;Change grep to:&lt;BR /&gt; &lt;BR /&gt;... | grep -i stuff&lt;BR /&gt;&lt;BR /&gt;... | grep -i stuff | grep -v grep&lt;BR /&gt; &lt;BR /&gt;This sometimes helps clean up the output.&lt;BR /&gt; &lt;BR /&gt;I'm attaching a script purely because it contains expamples. It will not help with your script except as a reference.&lt;BR /&gt; &lt;BR /&gt;SEP&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Sep 2003 14:26:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078623#M810907</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-09-25T14:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078624#M810908</link>
      <description>Good point, however, we limit the number of logins to 1 for most users.&lt;BR /&gt;&lt;BR /&gt;Also another problem, is the printing out to the testuser.txt file only writes out one user instead of the 3 or 4 that are in violation of this one hour rule.&lt;BR /&gt;&lt;BR /&gt;Thanks,</description>
      <pubDate>Thu, 25 Sep 2003 14:27:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078624#M810908</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2003-09-25T14:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078625#M810909</link>
      <description>Steven, your script is &lt;NULL&gt; and it can not be opened at my end, for whatever reason.  Can you post your script to the webpage so I can see what you mean, with the double grep.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;David, A timeout setting at the OS before the connection is closed on the DB side, can be dangerous for data corruption.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;/NULL&gt;</description>
      <pubDate>Thu, 25 Sep 2003 14:32:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078625#M810909</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2003-09-25T14:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078626#M810910</link>
      <description>Nick .. could you post us from your system the following.&lt;BR /&gt;&lt;BR /&gt;- Raw "who -u" output&lt;BR /&gt;- Copy of the idleusers.txt output file from the script run immeadiately after the who -u&lt;BR /&gt;&lt;BR /&gt;- Copy of the testuser.txt file immeadiatetly after 2nd script was run.&lt;BR /&gt;&lt;BR /&gt;My brain works better when I can analyze the data right in front of me.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Sep 2003 14:40:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078626#M810910</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-09-25T14:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078627#M810911</link>
      <description>And also, raw "ps -ef " output&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Sep 2003 14:44:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078627#M810911</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-09-25T14:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078628#M810912</link>
      <description>Just add &lt;BR /&gt;export TMOUT=1800 &lt;BR /&gt;to /etc/profile&lt;BR /&gt;and this will give a user short notification&lt;BR /&gt;and log him out after 30 mins of idling.&lt;BR /&gt;&lt;BR /&gt;It will not to try log off user if user have running editor (vi) or another interactive utility (sqlplus).&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Sep 2003 15:07:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078628#M810912</guid>
      <dc:creator>Sergey_27</dc:creator>
      <dc:date>2003-09-25T15:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078629#M810913</link>
      <description>Okay .. I think I have something working.&lt;BR /&gt;&lt;BR /&gt;You will need to modify the path names to match what you want, but this should work.&lt;BR /&gt;&lt;BR /&gt;First create a file called "useme.awk" which should contain:&lt;BR /&gt;&lt;BR /&gt;{index1=index($2,"tty");&lt;BR /&gt; if (index1==0)&lt;BR /&gt;   use2=$2&lt;BR /&gt; else&lt;BR /&gt;    use2=substr($2,index1);&lt;BR /&gt; print "ps -ef| grep _prog | grep " use2 "| grep -v grep" ;}&lt;BR /&gt;&lt;BR /&gt;NOTE: That print statement should be all one line.&lt;BR /&gt;&lt;BR /&gt;Then create a script file:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;touch useme1 useme2 useme3&lt;BR /&gt;rm useme1 useme2 useme3&lt;BR /&gt;who -u | grep old | cut -c1-24 &amp;gt; useme1&lt;BR /&gt;awk -f useme.awk &amp;lt; useme1 &amp;gt; useme2&lt;BR /&gt;chmod +x useme2&lt;BR /&gt;./useme2 &amp;gt; useme3&lt;BR /&gt;cat useme3 | while read LINE&lt;BR /&gt;do&lt;BR /&gt;USER=$(echo $LINE|awk '{print $1}')&lt;BR /&gt;mailx -s "You have been logged in too long" $USER &amp;lt; messagefile&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Also note, the script uses three temporary files  useme1, useme2, and useme3.&lt;BR /&gt;&lt;BR /&gt;And the script will mail a message called "messagefile" to the user.&lt;BR /&gt;&lt;BR /&gt;The logic is to find old logins with &lt;BR /&gt;who -u | grep old&lt;BR /&gt;&lt;BR /&gt;Then match the tty or pty to the ps output.&lt;BR /&gt;&lt;BR /&gt;Then email those users who matched.&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Once you've got a match</description>
      <pubDate>Thu, 25 Sep 2003 15:15:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078629#M810913</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-09-25T15:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078630#M810914</link>
      <description>&lt;PRE&gt;&lt;BR /&gt;[RE-POST in what is hopefully a more readable format ]&lt;BR /&gt;&lt;BR /&gt;Okay .. I think I have something working.&lt;BR /&gt;&lt;BR /&gt;You will need to modify the path names to match what you want, but this should work.&lt;BR /&gt;&lt;BR /&gt;First create a file called "useme.awk" which should contain:&lt;BR /&gt;&lt;BR /&gt;{index1=index($2,"tty");&lt;BR /&gt;if (index1==0)&lt;BR /&gt;use2=$2&lt;BR /&gt;else&lt;BR /&gt;use2=substr($2,index1);&lt;BR /&gt;&lt;BR /&gt;print "ps -ef| grep _prog | grep " use2 "| grep -v grep" ;}&lt;BR /&gt;&lt;BR /&gt;NOTE: That print statement should be all one line.&lt;BR /&gt;&lt;BR /&gt;Then create a script file:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;touch useme1 useme2 useme3&lt;BR /&gt;rm useme1 useme2 useme3&lt;BR /&gt;who -u | grep old | cut -c1-24 &amp;gt; useme1&lt;BR /&gt;awk -f useme.awk &amp;lt; useme1 &amp;gt; useme2&lt;BR /&gt;chmod +x useme2&lt;BR /&gt;./useme2 &amp;gt; useme3&lt;BR /&gt;cat useme3 | while read LINE&lt;BR /&gt;do&lt;BR /&gt;USER=$(echo $LINE|awk '{print $1}')&lt;BR /&gt;mailx -s "You have been logged in too long" $USER &amp;lt; messagefile&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Also note, the script uses three temporary files useme1, useme2, and useme3.&lt;BR /&gt;&lt;BR /&gt;And the script will mail a message called "messagefile" to the user so you need to create that.&lt;BR /&gt;&lt;BR /&gt;The logic is to find old logins with &lt;BR /&gt;who -u | grep old&lt;BR /&gt;&lt;BR /&gt;Then match the tty or pty to the ps output.&lt;BR /&gt;&lt;BR /&gt;Then email those users who matched.&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Sep 2003 15:17:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078630#M810914</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-09-25T15:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078631#M810915</link>
      <description>Kent,&lt;BR /&gt;&lt;BR /&gt;Very good, however, it appears that the script is only looking for the word old, and I need everything greater than 1.00 in that field.&lt;BR /&gt;&lt;BR /&gt;Thanks,</description>
      <pubDate>Mon, 29 Sep 2003 07:38:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078631#M810915</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2003-09-29T07:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078632#M810916</link>
      <description>You could also try one of the ndd params:&lt;BR /&gt;tcp_keepalive_interval.&lt;BR /&gt;This will timeout any connection that exceeds the keepalive interval. This is normally 2 hours, which is a little long to keep an invalid session hanging around.</description>
      <pubDate>Mon, 29 Sep 2003 08:40:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078632#M810916</guid>
      <dc:creator>Jakes Louw</dc:creator>
      <dc:date>2003-09-29T08:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078633#M810917</link>
      <description>Thanks for your feedback, however, if the user is idle and connected to a Unix DB, then we DO NOT want a kill signal or timeout sent to the PID as this could cause data corruption.&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Sep 2003 08:42:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078633#M810917</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2003-09-29T08:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078634#M810918</link>
      <description>Hi,&lt;BR /&gt; &lt;BR /&gt;if I understand this correctly, you could try and change this line in Kent's script:&lt;BR /&gt;who -u | grep old | cut -c1-24 &amp;gt; useme1&lt;BR /&gt;to:&lt;BR /&gt;who -u|awk ' $6 ~ /[1-9]:[0-9][0-9]/ {print $1,$2}' &amp;gt; useme1&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Sep 2003 08:52:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078634#M810918</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-09-29T08:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078635#M810919</link>
      <description>works like a charm.&lt;BR /&gt;&lt;BR /&gt;I modified the script so that it captures the user to a tmp file also so that I can keep track of consistantly deliquent users.&lt;BR /&gt;&lt;BR /&gt;Sorry Kent, I should have assigned you the points, please post one more time and I will assign points to you once more.&lt;BR /&gt;&lt;BR /&gt;Thank You,&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Sep 2003 09:02:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3078635#M810919</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2003-09-29T09:02:14Z</dc:date>
    </item>
  </channel>
</rss>

