<?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 please .. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671947#M51115</link>
    <description>(that first line got wrapped - 'while read name' should be together on the first line, 'do' on the second line)</description>
    <pubDate>Tue, 26 Feb 2002 22:06:53 GMT</pubDate>
    <dc:creator>Eric Ladner</dc:creator>
    <dc:date>2002-02-26T22:06:53Z</dc:date>
    <item>
      <title>script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671942#M51110</link>
      <description>Hey everyone ..&lt;BR /&gt;I am working on an auditing script to see how many times users log in and fail. I am working with the last,lastb, command and the su.log.&lt;BR /&gt;With the last commands I am doing &lt;BR /&gt;last | grep -v ftp # this is because there are allot of ftps going on and I am not too intrested in them. And I get output like so:&lt;BR /&gt;rleon    pts/te       Tue Feb 26 14:42 - 14:43  (00:00)&lt;BR /&gt;rgagnon  pts/tc       Tue Feb 26 14:29   still logged in&lt;BR /&gt;rleon    pts/ta       Tue Feb 26 14:28   still logged in&lt;BR /&gt;bkirk    pts/ta       Tue Feb 26 13:28 - 13:30  (00:01)&lt;BR /&gt;bconvers pts/te       Tue Feb 26 11:18 - 11:40  (00:22)&lt;BR /&gt;bkirk    pts/tg       Tue Feb 26 10:47 - 13:21  (02:34)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;How can redirect this output to be more of a port type output? For example&lt;BR /&gt;&lt;BR /&gt;rleon still loged in 1&lt;BR /&gt;rleon 1&lt;BR /&gt;bkirk 2&lt;BR /&gt;bconvers 1&lt;BR /&gt;&lt;BR /&gt;And so on. I have been working with awk but I cant get the right output. I know if I can get the right awk santax that I can fix them all to output right. &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Richard</description>
      <pubDate>Tue, 26 Feb 2002 20:42:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671942#M51110</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-02-26T20:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671943#M51111</link>
      <description>pipe the output through sort:&lt;BR /&gt;&lt;BR /&gt;last | grep -v ftp |sort&lt;BR /&gt;&lt;BR /&gt;the default behavior for sort is to sort on the first space-delimited field.  You can change this, man sort for more info.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;mark&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Feb 2002 20:53:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671943#M51111</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2002-02-26T20:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671944#M51112</link>
      <description>The sort command will sort for me .. and with &lt;BR /&gt;sort -k 6,6 sulog &lt;BR /&gt;or with the&lt;BR /&gt;last | grep -v ftp | sort&lt;BR /&gt;I can sort buy the users. But I still need a final count of the users. But just a list of the users. I need to turn this:&lt;BR /&gt;&lt;BR /&gt;ajohnson pts/ta       Tue Feb 26 08:05 - 08:05  (00:00)&lt;BR /&gt;rleon    pts/ta       Tue Feb 26 14:28 - 15:05  (00:36)&lt;BR /&gt;rleon    pts/tc       Tue Feb 26 15:37 - 15:41  (00:04)&lt;BR /&gt;rleon    pts/tc       Tue Feb 26 15:49   still logged in&lt;BR /&gt;rleon    pts/te       Tue Feb 26 14:42 - 14:43  (00:00)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;into this:&lt;BR /&gt;&lt;BR /&gt;ajohnson 1&lt;BR /&gt;rleon    4 &lt;BR /&gt;&lt;BR /&gt;And so on for all the users that come out with the last command. &lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Tue, 26 Feb 2002 21:55:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671944#M51112</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2002-02-26T21:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671945#M51113</link>
      <description>Pipe the output of the sort to "cut -f1" then "uniq -c", this will produce a count of each user.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 26 Feb 2002 22:03:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671945#M51113</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-02-26T22:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671946#M51114</link>
      <description>last | grep -v ftp | awk '{ print $1 }' | sort -u | while read name&lt;BR /&gt;do&lt;BR /&gt;  last | grep -v ftp | grep -c "^$name" | read count&lt;BR /&gt;  echo $name $count&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;That does the trick for counts per user.</description>
      <pubDate>Tue, 26 Feb 2002 22:05:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671946#M51114</guid>
      <dc:creator>Eric Ladner</dc:creator>
      <dc:date>2002-02-26T22:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671947#M51115</link>
      <description>(that first line got wrapped - 'while read name' should be together on the first line, 'do' on the second line)</description>
      <pubDate>Tue, 26 Feb 2002 22:06:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671947#M51115</guid>
      <dc:creator>Eric Ladner</dc:creator>
      <dc:date>2002-02-26T22:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671948#M51116</link>
      <description>Here's one that does it with the still logged in counts too (simple change).&lt;BR /&gt;&lt;BR /&gt;(see attached)</description>
      <pubDate>Tue, 26 Feb 2002 22:14:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671948#M51116</guid>
      <dc:creator>Eric Ladner</dc:creator>
      <dc:date>2002-02-26T22:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671949#M51117</link>
      <description>here's a quick and dirty one I kocked up for an audit over december. I haven't had time to fix it up, but it's a start.&lt;BR /&gt;&lt;BR /&gt;It's for a trusted system.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;SCRIPT=${0##*/}&lt;BR /&gt;TODAY=$(date)&lt;BR /&gt;TMPFILE=/tmp/$SCRIPT.tmp&lt;BR /&gt;LOGFILE=$SCRIPT.log&lt;BR /&gt;&lt;BR /&gt;get_users()&lt;BR /&gt;{&lt;BR /&gt;        cat /etc/passwd | cut -d: -f1 &amp;gt; $TMPFILE&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;check_last_login()&lt;BR /&gt;{&lt;BR /&gt;        while read user ; do&lt;BR /&gt;        LOCKED=`/usr/lbin/getprpw -m lockout $user | sed 's/lockout=//'`&lt;BR /&gt;        if [ $LOCKED -ne 0 ] ;&lt;BR /&gt;          then&lt;BR /&gt;            DISABLED="LOCKED OUT"&lt;BR /&gt;          else&lt;BR /&gt;            DISABLED=""&lt;BR /&gt;        fi&lt;BR /&gt;        LASTLOGIN=`/usr/lbin/getprpw -m slogint $user | sed 's/slogint=/'$user' /'`&lt;BR /&gt;        echo "\n$LASTLOGIN\t$DISABLED"&lt;BR /&gt;        done&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;get_users&lt;BR /&gt;echo "USERNAME   LAST LOGIN TIME"&lt;BR /&gt;check_last_login &amp;lt; $TMPFILE&lt;BR /&gt;&lt;BR /&gt;rm -rf $TMPFILE</description>
      <pubDate>Tue, 26 Feb 2002 22:18:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671949#M51117</guid>
      <dc:creator>Scott Van Kalken</dc:creator>
      <dc:date>2002-02-26T22:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671950#M51118</link>
      <description>Oh my, this would be far too much fuss for me to involve awk or so.&lt;BR /&gt;Instead a mere Perl one-liner does this&lt;BR /&gt;(might be improvable, since I just hacked it in at the shell prompt)&lt;BR /&gt;&lt;BR /&gt; last|perl -nae '$user{$F[0]}++ unless $F[0] eq "ftp";END{map {printf "%10s%6u\n",$_,$user{$_}} keys %user}'</description>
      <pubDate>Wed, 27 Feb 2002 16:55:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671950#M51118</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2002-02-27T16:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: script  help please ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671951#M51119</link>
      <description>Hi Richard:&lt;BR /&gt;&lt;BR /&gt;You might consider this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;last|sort -k1| awk 'NF&amp;gt;1 &amp;amp;&amp;amp; $2 !~/ftp/ &amp;amp;&amp;amp; $1!~/wtmp/ {&lt;BR /&gt;if (FIRST==0) {FIRST=1;USR=$1}&lt;BR /&gt;if (USR!=$1) {print USR,"ON="ON,"OFF="OFF;ON=0;OFF=0}&lt;BR /&gt;USR=$1&lt;BR /&gt;if ($7~/still/) {ON++} else {OFF++}&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 27 Feb 2002 18:36:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-please/m-p/2671951#M51119</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-02-27T18:36:36Z</dc:date>
    </item>
  </channel>
</rss>

