<?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: User last successful login in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407717#M202045</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can use the "last" command which gives you your desired output&lt;BR /&gt;&lt;BR /&gt;only last will give you the successful logins of all users&lt;BR /&gt;&lt;BR /&gt;if you use last &lt;USERNAME&gt; it'll give you the info only for that named user &lt;BR /&gt;You can customize the output using awk&lt;BR /&gt;&lt;BR /&gt;eg&lt;BR /&gt;&lt;BR /&gt;last &lt;USERNAME&gt; |awk '{print $1,$4,$5,$6}'&lt;BR /&gt;&lt;BR /&gt;lastb would be the contrary (unsuccessful logins) btw&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Franky&lt;/USERNAME&gt;&lt;/USERNAME&gt;</description>
    <pubDate>Tue, 26 Oct 2004 02:51:06 GMT</pubDate>
    <dc:creator>Franky_1</dc:creator>
    <dc:date>2004-10-26T02:51:06Z</dc:date>
    <item>
      <title>User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407714#M202042</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Is there any way or script to get all the users last successful login &amp;amp; pipe to a text file?&lt;BR /&gt;&lt;BR /&gt;Example the data captured is: &lt;BR /&gt;peter|24Oct2004&lt;BR /&gt;andrew|16Oct2004&lt;BR /&gt;&lt;BR /&gt;regards.</description>
      <pubDate>Tue, 26 Oct 2004 02:30:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407714#M202042</guid>
      <dc:creator>Ngoh Chean Siung</dc:creator>
      <dc:date>2004-10-26T02:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407715#M202043</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;just use &amp;gt; after the command you used to get the data captured.&lt;BR /&gt;Your question is a bit vague.&lt;BR /&gt;You can use cut or awk with field separator | to single out fields.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 02:39:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407715#M202043</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-10-26T02:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407716#M202044</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You could use the last command.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;for i in  $(cat /etc/passwd | awk -F: '( $3 &amp;gt; 100 ) { print $1 } ')&lt;BR /&gt;do&lt;BR /&gt;last -1 $i | awk '{ print $1"|"$5,$4 }'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Gideon&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 02:40:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407716#M202044</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2004-10-26T02:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407717#M202045</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can use the "last" command which gives you your desired output&lt;BR /&gt;&lt;BR /&gt;only last will give you the successful logins of all users&lt;BR /&gt;&lt;BR /&gt;if you use last &lt;USERNAME&gt; it'll give you the info only for that named user &lt;BR /&gt;You can customize the output using awk&lt;BR /&gt;&lt;BR /&gt;eg&lt;BR /&gt;&lt;BR /&gt;last &lt;USERNAME&gt; |awk '{print $1,$4,$5,$6}'&lt;BR /&gt;&lt;BR /&gt;lastb would be the contrary (unsuccessful logins) btw&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Franky&lt;/USERNAME&gt;&lt;/USERNAME&gt;</description>
      <pubDate>Tue, 26 Oct 2004 02:51:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407717#M202045</guid>
      <dc:creator>Franky_1</dc:creator>
      <dc:date>2004-10-26T02:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407718#M202046</link>
      <description>As long as I think your main problem is to get all logins, you can use the "last" command as root. It will give you all logins for all users.&lt;BR /&gt;&lt;BR /&gt;Parsing it with perl like this :&lt;BR /&gt;$ll="";&lt;BR /&gt;open(STDIN,"last|sort -k 1|");&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;  chomp;&lt;BR /&gt;  $cl=$_;&lt;BR /&gt;  ($user,@rest)=split /  */,$cl;&lt;BR /&gt;  ($luser,@rest)=split /  */,$ll;&lt;BR /&gt;  if ($user eq $luser) {&lt;BR /&gt;    $ll=$cl;&lt;BR /&gt;  } else {&lt;BR /&gt;        print "$ll\n";&lt;BR /&gt;        $ll=$cl;&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;print "$cl\n";&lt;BR /&gt;&lt;BR /&gt;will give you last line for each user. Modify it to get the output you want.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;/STDIN&gt;</description>
      <pubDate>Tue, 26 Oct 2004 02:51:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407718#M202046</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-10-26T02:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407719#M202047</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;What I want is to get the LATEST last login for each users. Example andrew has login to server in July and Aug, then the script will only retrieve a line of user id &amp;amp; the month is Aug. (No duplicated)&lt;BR /&gt;&lt;BR /&gt;Any idea?&lt;BR /&gt;&lt;BR /&gt;regards.</description>
      <pubDate>Tue, 26 Oct 2004 04:31:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407719#M202047</guid>
      <dc:creator>Ngoh Chean Siung</dc:creator>
      <dc:date>2004-10-26T04:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407720#M202048</link>
      <description>... That's exactly what my script did...&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 04:39:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407720#M202048</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-10-26T04:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407721#M202049</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;last -1 username&lt;BR /&gt;&lt;BR /&gt;check my previouse post, may be it has some errors but it does a grep on user stings in the passwd file, ( only users &amp;gt;100 as uid) and issue a last -1 on that user. Redirection to a file .. done &amp;gt;&amp;gt;file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Gideon</description>
      <pubDate>Tue, 26 Oct 2004 04:42:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407721#M202049</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2004-10-26T04:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407722#M202050</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Gideon&lt;BR /&gt;Your script is running but how to sort by alphabetical and display the year login? Beside that, why there is only "|" appears?&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;ehg|18 Oct&lt;BR /&gt;hamdanar|26 Oct&lt;BR /&gt;lkf|26 Oct&lt;BR /&gt;ckkhoo|26 Oct&lt;BR /&gt;leg|26 Oct&lt;BR /&gt;|&lt;BR /&gt;wtmp|8 Oct&lt;BR /&gt;|&lt;BR /&gt;wtmp|8 Oct&lt;BR /&gt;hcwong|26 Oct&lt;BR /&gt;|&lt;BR /&gt;wtmp|8 Oct&lt;BR /&gt;vasus|23 Sep&lt;BR /&gt;|&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;There is some errors when I am running your script.&lt;BR /&gt;&lt;BR /&gt;Error:&lt;BR /&gt;# sh user.sh&lt;BR /&gt;user.sh: =:  not found.&lt;BR /&gt;user.sh[2]: Syntax error at line 2 : `(' is not expected.&lt;BR /&gt;&lt;BR /&gt;regards</description>
      <pubDate>Tue, 26 Oct 2004 05:23:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407722#M202050</guid>
      <dc:creator>Ngoh Chean Siung</dc:creator>
      <dc:date>2004-10-26T05:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407723#M202051</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;In order to sort, use the sort command&lt;BR /&gt;...&lt;BR /&gt;done | sort &amp;gt;&amp;gt;file&lt;BR /&gt;&lt;BR /&gt;Why the only the "|" appears.. this can be the case when the user never logged in. &lt;BR /&gt;you can solv this by&lt;BR /&gt;..&lt;BR /&gt;done | grep -v ^| sort &amp;gt;&amp;gt;file&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Gideon</description>
      <pubDate>Tue, 26 Oct 2004 05:54:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407723#M202051</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2004-10-26T05:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407724#M202052</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It prompts me this error when I added the line that you proposed&lt;BR /&gt;&lt;BR /&gt;# sh user.sh&lt;BR /&gt;grep: illegal option -- ^&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...[-f pattern_file...] [file...]&lt;BR /&gt;&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]-f pattern_file...[file...]&lt;BR /&gt;&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]&lt;BR /&gt;&lt;BR /&gt;Btw, is it able to show the year login as well?&lt;BR /&gt;&lt;BR /&gt;regards.</description>
      <pubDate>Tue, 26 Oct 2004 06:09:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407724#M202052</guid>
      <dc:creator>Ngoh Chean Siung</dc:creator>
      <dc:date>2004-10-26T06:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407725#M202053</link>
      <description>Sorrie,&lt;BR /&gt;&lt;BR /&gt;done | grep -v "^|" | sort &amp;gt;&amp;gt; file&lt;BR /&gt;&lt;BR /&gt;As far as i know last does not print a year. &lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;&lt;BR /&gt;Gideon</description>
      <pubDate>Tue, 26 Oct 2004 06:17:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407725#M202053</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2004-10-26T06:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407726#M202054</link>
      <description>Errors on my script... maybe because it is a perl script. Not a shell one :)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 07:02:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407726#M202054</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-10-26T07:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407727#M202055</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;'one liner' in perl:&lt;BR /&gt;&lt;BR /&gt;last | perl -e 'while(&amp;lt;&amp;gt;){($u,$x,$x,$m,$d)=split; $all{$u}="$m $d" unless ($all{$u})} foreach (sort keys %all) {print "$_|$all{$_}\n" if ($_)}'&lt;BR /&gt;&lt;BR /&gt;- loop through input&lt;BR /&gt;- split by whitespace, remembering user, month, day&lt;BR /&gt;- remember date for user unless that user has a day already&lt;BR /&gt;- when all input processed, report on all remembered users, sorted.&lt;BR /&gt;&lt;BR /&gt;no, I do not knwo how a year change looks like. But a perl script like above is readily expanded to have a rolling months window where every month in this year prints the current year, and every 'future' month prints the last year.&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 07:26:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407727#M202055</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-10-26T07:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407728#M202056</link>
      <description>We can collect all normal users ( except system users) with listusers so that,&lt;BR /&gt;&lt;BR /&gt;for user in `listusers | awk '{ print $1 }'`&lt;BR /&gt;do&lt;BR /&gt;  last -1 $user | awk '{ print $1"|"$5$4 }'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;We can not get year informations from last output there.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Tue, 26 Oct 2004 08:02:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407728#M202056</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-26T08:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407729#M202057</link>
      <description>To get current year and more efficient manner then use as,&lt;BR /&gt;&lt;BR /&gt;# for user in `logins -u | awk '{ print $1 }'`&lt;BR /&gt;do&lt;BR /&gt;last -1 $user | grep -v '^wtmp begins' | awk '{ printf $1"|"$5$4;system("date +'%Y'") }'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Some user will not contain login details. That will show as wtmp begin.. information with log there.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 08:07:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407729#M202057</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-26T08:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: User last successful login</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407730#M202058</link>
      <description>&lt;BR /&gt;I needed a coffee break.. below a potential solution with year handling. It compares todays month and day ($M, $D) with the one in the last record ($m, $d) and adjust the year if deemed in the past.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;test.p:&lt;BR /&gt;($x,$x,$x,$D,$M,$Y)=localtime;&lt;BR /&gt;while(&amp;lt;&amp;gt;){&lt;BR /&gt; ($u,$x,$x,$m,$d)=split;&lt;BR /&gt; next if ($all{$u});&lt;BR /&gt; $y = $Y + 1900;&lt;BR /&gt; $i = index("JanFebMarAprMayJunJulAugSepOctNovDec",$m)/3;&lt;BR /&gt; next if ($i &amp;lt; 0);&lt;BR /&gt; $y-- if ($i &amp;gt; $M);&lt;BR /&gt; $y-- if ($i == $M &amp;amp;&amp;amp; $d &amp;gt; $D);&lt;BR /&gt; $all{$u}="|$m $d $y";&lt;BR /&gt; }&lt;BR /&gt; foreach (sort keys %all) {&lt;BR /&gt;   print "$_$all{$_}\n" if ($_);&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;Usage:&lt;BR /&gt;&lt;BR /&gt;last | perl test.p&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2004 08:22:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-last-successful-login/m-p/3407730#M202058</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-10-26T08:22:01Z</dc:date>
    </item>
  </channel>
</rss>

